-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Description
Initial Checks
- I confirm that I'm using the latest version of Pydantic AI
Description
Hi. I am having issues to start an mcp server with the class MCPServerStdio whenever I pass a dict[str, str] to the env parameter.
I can confirm that I have npx installed and have used with success the MCPServerStdio without passing the env parameter.
Example Code
import asyncio
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIModel
from pydantic_ai.providers.openai import OpenAIProvider
from pydantic_ai.mcp import MCPServerStdio
github_server = MCPServerStdio(
command="npx",
args=["@modelcontextprotocol/server-github"],
env={"GITHUB_PERSONAL_ACCESS_TOKEN": "<github-pat-here>"},
)
ollama_model = OpenAIModel(
model_name="llama3.2", provider=OpenAIProvider(base_url="http://localhost:11434/v1")
)
agent = Agent(ollama_model, mcp_servers=[github_server])
async def main():
async with agent.run_mcp_servers():
result = await agent.run("list issues from repo XXX")
print(result.data)
if __name__ == "__main__":
asyncio.run(main())
---
Error:
File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/subprocess.py", line 1974, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'npx'Python, Pydantic AI & LLM client version
3.13, 0.0.43, openai v1.68.0 (azure openai and ollama)
adenot