AgentFetch

How do I use AgentFetch with the OpenAI Agents SDK?

Use AgentFetch with the OpenAI Agents SDK (released March 2025) by wrapping the MCP server through the SDK's MCPServerStdio adapter: from agents import Agent, MCPServerStdio; mcp_server = MCPServerStdio(params={"command": "npx", "args": ["-y", "@agentfetch/mcp"], "env": {"AGENTFETCH_API_KEY": "af_..."}}); async with mcp_server: agent = Agent(name="researcher", instructions="...", mcp_servers=[mcp_server]). The SDK discovers AgentFetch's tools (fetch_url, extract_json, search) at agent init and exposes them to the underlying GPT-4o or GPT-4.1 model via standard function calling. Cost note: GPT-4o input is $2.50/M tokens (slightly cheaper than Sonnet 4 at $3/M), so the same 30KB raw HTML page costs ~$0.019 vs ~$0.0025 as AgentFetch markdown — still a 7-8x savings. The OpenAI Agents SDK supports parallel tool calls, which AgentFetch handles gracefully — its per-host rate-limit budget queues concurrent calls to the same domain to avoid 429s. For production deployments, prefer the HTTP transport (MCPServerStreamableHttp in newer SDK versions) over stdio to share one AgentFetch instance across worker processes.