jeevesagent.mcp.client

Per-server MCP client wrapping mcp.ClientSession lifetime.

The mcp SDK is imported lazily inside MCPClient.connect(). Tests can bypass the real connection entirely by passing a session= kwarg whose object exposes the methods we use: initialize(), list_tools(), call_tool(name, args).

Classes

MCPClient

One client per MCP server. Holds the live ClientSession.

Module Contents

class jeevesagent.mcp.client.MCPClient(spec: jeevesagent.mcp.spec.MCPServerSpec, *, session: Any | None = None)[source]

One client per MCP server. Holds the live ClientSession.

async aclose() None[source]

Tear down the session and underlying transport.

async call_tool(name: str, args: dict[str, Any]) Any[source]

Invoke name with args. Returns the SDK’s CallToolResult.

async connect() None[source]

Open the transport and initialise the session.

No-op if already connected (or a fake session was injected at construction time).

async list_tools() list[Any][source]

Return whatever the SDK gave us — a list of tool descriptors.

Each descriptor has name, description, inputSchema. We don’t translate to ToolDef here — the registry does that, since it also assigns names with disambiguation.

property is_connected: bool
property name: str
property spec: jeevesagent.mcp.spec.MCPServerSpec