Skip to content

Commit f68660d

Browse files
committed
switch to mcp-run-python for the mcp servers
1 parent 9f26b28 commit f68660d

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

pydantic_ai_slim/pydantic_ai/toolsets/fastmcp.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,8 @@ def from_mcp_server(
174174
from pydantic_ai.toolsets.fastmcp import FastMCPToolset
175175
176176
time_mcp_server = {
177-
'command': 'uvx',
178-
'args': [
179-
'mcp-server-time',
180-
]
177+
'command': 'uv',
178+
'args': ['run', 'mcp-run-python', 'stdio'],
181179
}
182180
183181
toolset = FastMCPToolset.from_mcp_server(name='time_server', mcp_server=time_mcp_server)
@@ -199,36 +197,33 @@ def from_mcp_config(
199197
"""Build a FastMCPToolset from an MCP json-derived / dictionary configuration object.
200198
201199
Example:
202-
```python
200+
```python
203201
from pydantic_ai import Agent
204202
from pydantic_ai.toolsets.fastmcp import FastMCPToolset
205203
206204
mcp_config = {
207205
'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'],
213209
},
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'],
219213
}
220214
}
221215
}
222216
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])
224220
225-
agent = Agent('openai:gpt-4o', toolsets=[fastmcp_toolset])
226221
async def main():
227222
async with agent: # (1)!
228223
...
229224
```
230225
231-
1. This will start both MCP Servers running over stdio`.
226+
1. This will start the MCP Servers running over stdio.
232227
"""
233228
transport: MCPConfigTransport = MCPConfigTransport(config=mcp_config)
234229
fastmcp_client: Client[MCPConfigTransport] = Client[MCPConfigTransport](transport=transport)

0 commit comments

Comments
 (0)