@@ -174,10 +174,8 @@ def from_mcp_server(
174
174
from pydantic_ai.toolsets.fastmcp import FastMCPToolset
175
175
176
176
time_mcp_server = {
177
- 'command': 'uvx',
178
- 'args': [
179
- 'mcp-server-time',
180
- ]
177
+ 'command': 'uv',
178
+ 'args': ['run', 'mcp-run-python', 'stdio'],
181
179
}
182
180
183
181
toolset = FastMCPToolset.from_mcp_server(name='time_server', mcp_server=time_mcp_server)
@@ -199,36 +197,33 @@ def from_mcp_config(
199
197
"""Build a FastMCPToolset from an MCP json-derived / dictionary configuration object.
200
198
201
199
Example:
202
- ```python
200
+ ```python
203
201
from pydantic_ai import Agent
204
202
from pydantic_ai.toolsets.fastmcp import FastMCPToolset
205
203
206
204
mcp_config = {
207
205
'mcpServers': {
208
- 'time_server': {
209
- 'command': 'uvx',
210
- 'args': [
211
- 'mcp-server-time',
212
- ]
206
+ 'first_server': {
207
+ 'command': 'uv',
208
+ 'args': ['run', 'mcp-run-python', 'stdio'],
213
209
},
214
- 'fetch_server': {
215
- 'command': 'uvx',
216
- 'args': [
217
- 'mcp-server-fetch',
218
- ]
210
+ 'second_server': {
211
+ 'command': 'uv',
212
+ 'args': ['run', 'mcp-run-python', 'stdio'],
219
213
}
220
214
}
221
215
}
222
216
223
- fastmcp_toolset = FastMCPToolset.from_mcp_config(mcp_config)
217
+ toolset = FastMCPToolset.from_mcp_config(mcp_config)
218
+
219
+ agent = Agent('openai:gpt-4o', toolsets=[toolset])
224
220
225
- agent = Agent('openai:gpt-4o', toolsets=[fastmcp_toolset])
226
221
async def main():
227
222
async with agent: # (1)!
228
223
...
229
224
```
230
225
231
- 1. This will start both MCP Servers running over stdio` .
226
+ 1. This will start the MCP Servers running over stdio.
232
227
"""
233
228
transport : MCPConfigTransport = MCPConfigTransport (config = mcp_config )
234
229
fastmcp_client : Client [MCPConfigTransport ] = Client [MCPConfigTransport ](transport = transport )
0 commit comments