This commit is contained in:
Jeremiah Lowin 2025-05-20 21:10:44 -04:00
commit b2dc2f0473
4 changed files with 23 additions and 3 deletions

View file

@ -253,6 +253,29 @@ async def main():
# ... use the client
```
FastMCP also supports connecting to multiple servers through a single unified client using the standard MCP configuration format:
```python
from fastmcp import Client
# Standard MCP configuration with multiple servers
config = {
"mcpServers": {
"weather": {"url": "https://weather-api.example.com/mcp"},
"assistant": {"command": "python", "args": ["./assistant_server.py"]}
}
}
# Create a client that connects to all servers
client = Client(config)
async def main():
async with client:
# Access tools and resources with server prefixes
forecast = await client.call_tool("weather_get_forecast", {"city": "London"})
answer = await client.call_tool("assistant_answer_question", {"query": "What is MCP?"})
```
Learn more in the [**Client Documentation**](https://gofastmcp.com/clients/client) and [**Transports Documentation**](https://gofastmcp.com/clients/transports).
## Advanced Features

View file

@ -95,7 +95,6 @@ When you create a client with an `MCPConfig` containing multiple servers:
```python
from fastmcp import Client
from fastmcp.utilities.mcp_config import MCPConfig
# Create a standard MCP configuration with multiple servers
config = {

View file

@ -333,7 +333,6 @@ MCPConfig follows an emerging standard for MCP server configuration but is subje
```python
from fastmcp import Client
from fastmcp.utilities.mcp_config import MCPConfig
# Configuration for multiple MCP servers (both local and remote)
config = {

View file

@ -18,7 +18,6 @@ def iter_exc(group: BaseExceptionGroup):
def _exception_handler(group: BaseExceptionGroup):
print(list(iter_exc(group)))
for leaf in iter_exc(group):
if isinstance(leaf, httpx.ConnectTimeout):
raise McpError(