Raxol.MCP.Transport.Stdio (Raxol MCP v2.6.0)

Copy Markdown View Source

Stdio transport for MCP.

Reads JSON-RPC messages line-by-line from stdin, routes them to the MCP Server, and writes responses to stdout. This is the transport used by Claude Code and other CLI MCP clients.

Notifications

Subscribes to the MCP Server for push notifications (e.g. notifications/tools/list_changed). Notifications are written to stdout as unsolicited JSON-RPC messages.

Important

When using this transport, configure Logger to write to stderr to avoid corrupting the JSON-RPC stream on stdout:

config :logger, :default_handler, %{config: %{type: :standard_error}}

Or at runtime:

Logger.configure_backend(:console, device: :standard_error)

Summary

Types

t()

@type t() :: %Raxol.MCP.Transport.Stdio{
  io_device: IO.device(),
  output_device: IO.device(),
  reader_ref: reference() | nil,
  server: GenServer.server()
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

handle_manager_call(request, from, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_call/3.

handle_manager_cast(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_cast/2.

start_link(init_opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Start the stdio transport.

Options

  • :server -- MCP Server pid or name (default: Raxol.MCP.Server)
  • :name -- GenServer name (optional)
  • :io_device -- input device (default: :stdio), useful for testing
  • :output_device -- output device (default: :stdio), useful for testing