ExAthena.Mcp.Server (ExAthena v0.6.0)

Copy Markdown View Source

Per-MCP-server GenServer. Owns one Client and the cached tool catalog.

Lifecycle:

  1. init/1 registers in the Registry and sends itself :boot.
  2. handle_info(:boot, ...) starts the Client, runs tools/list, caches tools.
  3. Status transitions: :starting:ready (success) or :degraded (failure).

Linked to its Client: if the Client crashes, this process also crashes so the Supervisor can restart both.

Summary

Functions

Forward a tool call to the underlying client. Returns {:ok, result_map} or {:error, reason}.

Returns a specification to start this module under a supervisor.

Return {:ok, client_pid} when ready, {:error, reason} otherwise.

Return metadata map for list_servers/0.

Return cached tools. {:ok, [tool_map]} when ready, {:error, reason} otherwise.

Start and link a server process registered under cfg.name.

Functions

call_tool(server, tool_name, args, timeout \\ 30000)

@spec call_tool(GenServer.server(), String.t(), map(), non_neg_integer()) ::
  {:ok, map()} | {:error, term()}

Forward a tool call to the underlying client. Returns {:ok, result_map} or {:error, reason}.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_client(server)

@spec get_client(GenServer.server()) :: {:ok, pid()} | {:error, term()}

Return {:ok, client_pid} when ready, {:error, reason} otherwise.

info(server)

@spec info(GenServer.server()) :: {:ok, map()}

Return metadata map for list_servers/0.

list_tools(server)

@spec list_tools(GenServer.server()) :: {:ok, [map()]} | {:error, term()}

Return cached tools. {:ok, [tool_map]} when ready, {:error, reason} otherwise.

start_link(cfg)

Start and link a server process registered under cfg.name.