Snodo.Client.Stdio (snodo v0.1.0)

Copy Markdown View Source

Stdio transport for Snodo.Client.connect({:stdio, command, args}, opts).

A process owns a Port running command. It writes one JSON-RPC message per line to the server's stdin and reads newline-delimited messages from its stdout. The server's stderr is not captured. Responses are correlated by ID, so any number of processes can share one client and have requests in flight at once.

Options:

  • :env - extra environment variables, as {name, value} string pairs. A nil value unsets the variable.
  • :cd - the working directory for the command.
  • :max_line_bytes - the largest response line to accept, default 16 MiB. The rest of a longer line is discarded as it arrives, so the request it answered times out; later responses are unaffected.

The connection process monitors the process that called connect/2 and closes when it exits. When a request times out, the transport answers the caller with a -32001 error and sends the server notifications/cancelled for that request ID. When the server exits, requests in flight and later requests fail with -32000. Server-to-client requests are answered with -32601, and server notifications are dropped.

close/1 closes the server's stdin. An MCP stdio server exits at EOF after finishing admitted requests; this transport does not signal or kill it.

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.