MCP.Transport.Stdio (MCP Elixir SDK v1.1.0)

Copy Markdown View Source

Stdio transport for MCP.

Communicates via newline-delimited JSON-RPC over stdin/stdout.

Client mode

Launches a subprocess via an Erlang Port. Messages are written as JSON + newline to the subprocess's stdin, and read as newline-delimited JSON from stdout. Stderr goes to the parent process's stderr.

Server mode

Reads from the process's own stdin and writes to stdout. Used when this Elixir process IS the MCP server subprocess.

Options

  • :owner (required) — pid to receive {:mcp_message, map} and {:mcp_transport_closed, reason} messages
  • :command — path to executable (client mode). When provided, a subprocess is spawned.
  • :args — arguments for the command (default: [])
  • :env — environment variables as [{String.t(), String.t()}]
  • :mode:client (default when :command given) or :server

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.