Hermes.Server.Transport.STDIO (hermes_mcp v0.10.1)
STDIO transport implementation for MCP servers.
This module handles communication with MCP clients via standard input/output streams, processing incoming JSON-RPC messages and forwarding responses.
Summary
Functions
Returns a specification to start this module under a supervisor.
Sends a message to the client via stdout.
Shuts down the transport connection.
Starts a new STDIO transport process.
Types
@type option() :: {:server, GenServer.server()} | {:name, GenServer.name()} | GenServer.option()
STDIO transport options
:server
- The server process (required):name
- Optional name for registering the GenServer
@type t() :: GenServer.server()
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec send_message(GenServer.server(), binary()) :: :ok | {:error, term()}
Sends a message to the client via stdout.
Parameters
transport
- The transport processmessage
- The message to send
Returns
:ok
if message was sent successfully{:error, reason}
otherwise
@spec shutdown(GenServer.server()) :: :ok
Shuts down the transport connection.
Parameters
transport
- The transport process
@spec start_link(Enumerable.t(option())) :: GenServer.on_start()
Starts a new STDIO transport process.
Parameters
opts
- Options:server
- (required) The server to forward messages to:name
- Optional name for the GenServer process
Examples
iex> Hermes.Server.Transport.STDIO.start_link(server: my_server)
{:ok, pid}