Mead.MCP.Transport.Stdio (mead v0.1.1)

Copy Markdown View Source

Runs an MCP server as a child process and talks to it over its standard input and output, one JSON message per line.

Options

  • :command - the executable, looked up on the PATH (required).
  • :arguments - a list of binaries; defaults to [].
  • :maximum_message_bytes - the longest message accepted; defaults to 4 MiB. A longer one closes the transport with :message_too_large instead of growing without bound.
  • :exit_grace_milliseconds - how long a child gets to leave after its stdin closes before it is sent SIGTERM; defaults to 1 000. A child that is still alive 500 ms after SIGTERM receives SIGKILL.

The child's standard error is not read: it goes to the terminal of the Erlang VM, which keeps the progress chatter that tools such as npx print out of the protocol stream.

Port.close/1 does not end the child, so stopping this transport closes stdin (which makes a well-behaved server exit) and then signals the child that stays. A server started through a wrapper such as npx may leave a grandchild that shares the wrapper's stdin and ends with it; a grandchild that ignores stdin closing is not tracked.

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.