Newline-delimited JSON framing for the MCP stdio binding.
Summary
Functions
Decodes one line of JSON. A trailing newline and carriage return, and a leading UTF-8 byte order mark, are ignored.
Encodes one message as a line of JSON.
Functions
@spec decode_line(iodata()) :: {:ok, term()} | {:error, Snodo.Error.t()}
Decodes one line of JSON. A trailing newline and carriage return, and a leading UTF-8 byte order mark, are ignored.
Encodes one message as a line of JSON.
Every character outside ASCII is written as a JSON \uXXXX escape, with a
surrogate pair above U+FFFF. The line is then the same bytes whatever the
output device's encoding. Raw UTF-8 written with IO.binwrite/2 to a
Unicode-mode device, which :stdio is under elixir, would be encoded a
second time. The escapes also keep U+2028 and U+2029 out of the stream.