Hermes.Client.Supervisor (hermes_mcp v0.10.1)
Supervisor for MCP client processes.
This module manages the lifecycle of both the MCP client and its associated
transport process. It uses a :one_for_all
strategy, meaning if either the
client or transport crashes, both are restarted together to maintain consistency.
The supervisor automatically:
- Starts the appropriate transport based on configuration
- Starts the client with a reference to the transport
- Ensures proper initialization order (transport first, then client)
- Handles process naming for both client and transport
Process Naming
- Client process: Uses the module name or custom
:name
option - Transport process: Named as
Module.concat(ClientName, "Transport")
Transport Configuration
Supports all Hermes transport types:
:stdio
- For command-line MCP servers:sse
- For Server-Sent Events transports:websocket
- For WebSocket connections:streamable_http
- For streaming HTTP transports
Summary
Functions
Returns a specification to start this module under a supervisor.
Starts the client supervisor.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec start_link( module(), keyword() ) :: Supervisor.on_start()
Starts the client supervisor.
Arguments
client_module
- The client module usingHermes.Client
opts
- Supervisor options including::name
- Optional custom name for the client process:transport
- Transport configuration (required):transport_name
- Optional custom name for the transport process:client_info
- Client identification info:capabilities
- Client capabilities map:protocol_version
- MCP protocol version
Examples
# Simple usage with module names
Hermes.Client.Supervisor.start_link(MyApp.MCPClient,
transport: {:stdio, command: "mcp", args: ["server"]},
client_info: %{"name" => "MyApp", "version" => "1.0.0"},
capabilities: %{"roots" => %{}},
protocol_version: "2024-11-05"
)
# With custom names (e.g., for distributed systems)
Hermes.Client.Supervisor.start_link(MyApp.MCPClient,
name: {:via, Horde.Registry, {MyCluster, "client_1"}},
transport_name: {:via, Horde.Registry, {MyCluster, "transport_1"}},
transport: {:stdio, command: "mcp", args: ["server"]},
client_info: %{"name" => "MyApp", "version" => "1.0.0"},
capabilities: %{"roots" => %{}},
protocol_version: "2024-11-05"
)