AgentFetch

How do I use AgentFetch with LangChain?

Use AgentFetch with LangChain via the langchain-mcp-adapters package: pip install langchain-mcp-adapters, then from langchain_mcp_adapters.client import MultiServerMCPClient; client = MultiServerMCPClient({"agentfetch": {"command": "npx", "args": ["-y", "@agentfetch/mcp"], "transport": "stdio"}}); tools = await client.get_tools(). Pass tools into any LangChain agent constructor — create_react_agent, create_tool_calling_agent, or LangGraph's ToolNode. The wrapper handles the MCP handshake, schema translation, and lifecycle (spawn/health-check/kill). Total integration is ~10 lines. AgentFetch's tools appear as standard LangChain BaseTool objects, so streaming, intermediate-step capture, callbacks, and LangSmith tracing all work normally. Production tip: spawn the MCP client once at app startup, not per-request — stdio process startup is ~200-500ms and you don't want that on every agent invocation. For high-concurrency deployments, use AgentFetch's HTTP transport instead of stdio: {"transport": "streamable-http", "url": "https://api.agentfetch.dev/mcp/"} plus AGENTFETCH_API_KEY. The same pattern works for LangGraph; just pass tools to ToolNode or bind_tools() on the model.