Something went wrong. Try again.
mirror of github.com/PrefectHQ/fastmcp
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114---title: groupsidebarTitle: group---
# `fastmcp.client.group`
Coordination of independent MCP client connections.
## Classes
### `ToolRoute` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/client/group.py#L24" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
The client and upstream name behind a public group tool name.
### `ClientGroup` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/client/group.py#L32" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
Coordinate independent clients without introducing a proxy server.
Each client retains its own transport, session, capabilities, and protocolversion. The group only combines tool discovery and routes tool calls.
Callers may manage the clients' connections themselves or use the group asa convenience context manager. The group's context is reentrant in thesame way a client's is: entries are reference counted, the first entryconnects every client, and the last exit disconnects them. Entering analready-connected FastMCP client is likewise safe because client contextsare reference counted.
**Methods:**
#### `clients` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/client/group.py#L61" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonclients(self) -> Mapping[str, Client[Any]]```
The group's clients, keyed by server name.
Read-only: membership is fixed at construction, since discovered routeshold the client that advertised each tool and would silently go staleif the mapping were swapped underneath them.
#### `from_config` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/client/group.py#L71" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonfrom_config(cls, config: MCPConfig | dict[str, Any]) -> ClientGroup```
Create one independent client for each configured server.
A server entry may include a FastMCP-specific ``mode`` field. It appliesonly to that server; entries without one use ``default_mode``.
#### `protocol_versions` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/client/group.py#L96" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonprotocol_versions(self) -> dict[str, str | None]```
#### `list_tools` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/client/group.py#L183" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonlist_tools(self) -> list[mcp_types.Tool]```
List tools from every client with namespaced names.
An explicit call is the group's catalog-refresh mechanism, so itdefaults to `cache_mode="refresh"`: a client-side response cache(SEP-2549) is repopulated rather than served, and the routes reflectwhat every server advertises now. Pass `cache_mode="use"` to allowcache hits when staleness within the server's hint is acceptable.
#### `resolve_tool` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/client/group.py#L220" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonresolve_tool(self, name: str) -> ToolRoute```
Resolve a public tool name to its client and upstream identity.
A known route only requires its own client to be connected; one deadserver does not couple failures onto calls routed to healthy servers.Loading the catalog (the first resolution, or after a refresh) stillrequires every client, since discovery queries them all.
#### `call_tool_mcp` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/client/group.py#L255" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythoncall_tool_mcp(self, name: str, arguments: dict[str, Any] | None = None) -> mcp_types.CallToolResult```
Call a namespaced tool and return its raw MCP result.
#### `call_tool` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/client/group.py#L274" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythoncall_tool(self, name: str, arguments: dict[str, Any] | None = None) -> CallToolResult```
Call a namespaced tool through the client that advertised it.