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

Types

STDIO transport options

t()

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

option()

@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

t()

@type t() :: GenServer.server()

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_schema(atom)

parse_options(data)

parse_options!(data)

send_message(transport, message)

@spec send_message(GenServer.server(), binary()) :: :ok | {:error, term()}

Sends a message to the client via stdout.

Parameters

  • transport - The transport process
  • message - The message to send

Returns

  • :ok if message was sent successfully
  • {:error, reason} otherwise

shutdown(transport)

@spec shutdown(GenServer.server()) :: :ok

Shuts down the transport connection.

Parameters

  • transport - The transport process

start_link(opts)

@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}