ExMCP.Transport.Stdio (ex_mcp v0.9.2)

View Source

This module implements the standard MCP specification.

stdio transport implementation for MCP.

This transport communicates with MCP servers over standard input/output, typically by spawning a subprocess. This is one of the two official MCP transports defined in the specification.

Options

  • :command - Command and arguments to spawn (required)
  • :cd - Working directory for the process
  • :env - Environment variables as a list of {"KEY", "VALUE"} tuples

Example

{:ok, client} = ExMCP.Client.start_link(
  transport: :stdio,
  command: ["node", "my-mcp-server.js"],
  cd: "/path/to/server",
  env: [{"NODE_ENV", "production"}]
)

Summary

Functions

Subscribe to receive transport events (push model).

Functions

recv(state, timeout \\ 5000)

send(state, message)

subscribe(pid, state)

Subscribe to receive transport events (push model).

Spawns an internal reader process that takes over port ownership, reads and parses JSON messages, and pushes them to the subscriber.