JSON-RPC 2.0 MCP client GenServer.
Manages a single MCP server connection over either:
:stdiotransport — spawns a child process and communicates via stdin/stdout:httptransport — POSTs JSON-RPC messages to an HTTP endpoint
Options
:command— executable name (required for stdio):args— argument list (default[], stdio only):env— environment map (default%{}, stdio only):url— HTTP endpoint URL (required for HTTP):headers— HTTP headers map (default%{}, HTTP only):request_timeout_ms— per-request timeout in ms (default 30_000):auto_initialize?— run initialize handshake ininit/1(defaulttrue)
Summary
Functions
Call a tool by name with input map. Returns {:ok, result_map} or {:error, reason}.
Returns a specification to start this module under a supervisor.
Run the initialize handshake. Only needed when auto_initialize?: false.
List tools exposed by the MCP server. Returns {:ok, [tool_map]} or {:error, reason}.
Start the client. Links the calling process.
Functions
@spec call_tool(GenServer.server(), String.t(), map(), non_neg_integer()) :: {:ok, map()} | {:error, term()}
Call a tool by name with input map. Returns {:ok, result_map} or {:error, reason}.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec initialize(GenServer.server(), non_neg_integer()) :: :ok | {:error, ExAthena.Error.t()}
Run the initialize handshake. Only needed when auto_initialize?: false.
@spec list_tools(GenServer.server(), non_neg_integer()) :: {:ok, [map()]} | {:error, term()}
List tools exposed by the MCP server. Returns {:ok, [tool_map]} or {:error, reason}.
@spec start_link(keyword()) :: GenServer.on_start()
Start the client. Links the calling process.