meta_mcp.mcp#
Attributes#
Classes#
FastMCP subclass that manages shared MCP client sessions with dynamic client management. |
Module Contents#
- class meta_mcp.mcp.MetaFastMCPDynamic(registry_json: str, registry_mcp_json: str, registry_mcp_tools_json: str, connect_on_startup: bool = False, *, name: str = 'meta-mcp', **kwargs: Any)#
Bases:
fastmcp.FastMCPFastMCP subclass that manages shared MCP client sessions with dynamic client management.
- _connect_on_startup = False#
- _registry_config#
- _registry_info#
- _registry_mcp_tools#
- _dynamic_client_stacks: dict[str, contextlib.AsyncExitStack]#
- _filter_and_setup_registry(registry_df)#
- async _update_tools_from_client(server_name: str, client: fastmcp.Client) None#
Update tool metadata for a server from a connected client.
- async _lifespan(_app: fastmcp.FastMCP)#
- async add_client(server_name: str, server_config: dict[str, Any]) None#
Add a new client at runtime.
- Args:
server_name: Name to identify this server server_config: MCP server configuration dict (should have ‘mcpServers’ key)
- Raises:
RuntimeError – If clients are not initialized or server already exists:
Exception – If client connection fails:
- async remove_client(server_name: str) None#
Remove a dynamically-managed client at runtime.
- Args:
server_name: Name of the server to remove
- Raises:
RuntimeError – If server doesn’t exist or is lifespan-managed:
- get_client(server_name: str) fastmcp.Client#
Get a client by name (from either pool).
- Parameters:
server_name (str) – Name of the server.
- Returns:
Client instance.
- Return type:
Client
- Raises:
RuntimeError – If clients are not initialized or server doesn’t exist:
- get_clients() dict[str, fastmcp.Client]#
Get all clients (both lifespan and dynamic).
- Returns:
Combined dictionary of all clients.
- Return type:
- Raises:
RuntimeError – If clients are not initialized:
- get_lifespan_clients() dict[str, fastmcp.Client]#
Get only lifespan-managed clients.
- Returns:
Dictionary of lifespan-managed clients.
- Return type:
- Raises:
RuntimeError – If clients are not initialized:
- meta_mcp.mcp._connect_on_startup#
- meta_mcp.mcp._registry_json#
- meta_mcp.mcp._registry_mcp_json#
- meta_mcp.mcp._registry_mcp_tools_json#
- meta_mcp.mcp.mcp: MetaFastMCPDynamic#