jeevesagent.mcp¶
Model Context Protocol (MCP) integration.
MCPServerSpec— declarative description of an MCP server (transport + connection details).MCPClient— wraps a singlemcp.ClientSession. ThemcpSDK is imported lazily insideMCPClient.connect()so the module loads without themcpextra installed; the import fires only when actually connecting to a real server.MCPRegistry— implementsToolHostover N MCP servers. Connects all servers in parallel through ananyio.create_task_group(), builds a tool name index with auto-disambiguation, and routescall(tool, args)to the right session.
Submodules¶
Classes¶
One client per MCP server. Holds the live |
|
Aggregates many |
|
How to find and talk to a single MCP server. |
Package Contents¶
- class jeevesagent.mcp.MCPClient(spec: jeevesagent.mcp.spec.MCPServerSpec, *, session: Any | None = None)[source]¶
One client per MCP server. Holds the live
ClientSession.- async call_tool(name: str, args: dict[str, Any]) Any[source]¶
Invoke
namewithargs. 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 toToolDefhere — the registry does that, since it also assigns names with disambiguation.
- property spec: jeevesagent.mcp.spec.MCPServerSpec¶
- class jeevesagent.mcp.MCPRegistry(items: list[jeevesagent.mcp.spec.MCPServerSpec | jeevesagent.mcp.client.MCPClient] | None = None)[source]¶
Aggregates many
MCPClientinstances into a singleToolHost.- async call(tool: str, args: collections.abc.Mapping[str, Any], *, call_id: str = '') jeevesagent.core.types.ToolResult[source]¶
- async watch() collections.abc.AsyncIterator[jeevesagent.core.types.ToolEvent][source]¶
listChangednotifications. Not yet implemented; yields nothing.
- class jeevesagent.mcp.MCPServerSpec[source]¶
How to find and talk to a single MCP server.
Construct via the class methods
stdio()orhttp()rather than the bare constructor — they enforce the right combination of fields per transport.- classmethod http(name: str, url: str, headers: dict[str, str] | None = None, *, description: str = '') MCPServerSpec[source]¶
Connect to
urlvia Streamable HTTP transport.
- classmethod stdio(name: str, command: str, args: list[str] | tuple[str, Ellipsis] | None = None, env: dict[str, str] | None = None, *, description: str = '') MCPServerSpec[source]¶
Spawn
commandas a subprocess and speak JSON-RPC over its stdio.
- transport: Literal['stdio', 'http']¶