tavily-mcp MCP server in LangChain MCP tools as LangChain tools.
LangChain has no config file for MCP — you wire servers up in code with langchain-mcp-adapters. Here's how to load tavily-mcp (2.1k stars) into an agent so it gets Tavily web search as a native tool.
Unlike desktop MCP clients, LangChain integrates MCP servers programmatically. The langchain-mcp-adapters package spawns the server, performs the MCP handshake, and converts each exposed tool into a LangChain-compatible tool object your agent can bind like any other.
tavily-mcp is a stdio server distributed on npm, so LangChain launches it through npx as a subprocess. That means Node.js must be installed wherever your Python (or JS) agent runs — including inside any container image you deploy.
Install the adapter
In your Python environment: pip install langchain-mcp-adapters langgraph. You also need a Tavily API key from tavily.com — the server reads it from a TAVILY_API_KEY environment variable that you pass explicitly in the connection config.
There's a subtlety worth knowing before you write code: Tavily also publishes first-party LangChain integrations that hit their API directly. Going through tavily-mcp instead makes sense when you want one MCP wiring pattern for all your tools, or when you're testing the same server you'll ship to MCP-native clients.
Connect with MultiServerMCPClient
MultiServerMCPClient takes a dict of server configs. For a stdio server like tavily-mcp you give it the command, args, and env; get_tools() returns LangChain tool objects ready to bind to a model or hand to a LangGraph agent:
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
client = MultiServerMCPClient({
"tavily": {
"transport": "stdio",
"command": "npx",
"args": ["-y", "tavily-mcp"],
"env": {"TAVILY_API_KEY": "tvly-YOUR_API_KEY"},
}
})
tools = await client.get_tools()
agent = create_react_agent("anthropic:claude-sonnet-4-5", tools)
result = await agent.ainvoke(
{"messages": "What changed in the latest MCP spec revision?"}
)Run it and watch the tool calls
The adapter API is async — get_tools() and agent invocation both need an event loop, so run this under asyncio.run() or inside an async framework. On first execution npx downloads the tavily-mcp package, which adds a few seconds; subsequent runs start from cache.
Print [t.name for t in tools] after loading to confirm what the server exposed. Your agent will then select Tavily's search tool whenever a prompt needs live web data, and you'll see the call in your traces if you run LangSmith.
Troubleshooting code-level setups
FileNotFoundError or spawn failure on npx: Node.js isn't installed or isn't on PATH for the process running Python — the classic case is a Docker image with Python but no Node. Install Node in the image or switch to a base that has both.
get_tools() hangs: the subprocess started but the handshake stalled, usually because the package printed an error instead of speaking MCP. Run npx -y tavily-mcp in a terminal to see its stderr directly. Auth errors at call time mean the TAVILY_API_KEY in the env dict is wrong — note the env dict replaces inherited variables for that subprocess in many setups, so pass everything the server needs explicitly.
The server in the wider index
tavily-mcp's listing and live tool list are on Loomal at https://loomal.ai/marketplace/tavily-mcp. The MCP server is open source; Tavily meters API usage under your key. If you're building agents that should discover and pay for tools at runtime rather than ship with hardcoded keys, Loomal's index serves x402-ready endpoints agents can pay per call in USDC on Base.
FAQ
How do I use tavily-mcp with LangChain?
Install langchain-mcp-adapters, create a MultiServerMCPClient with a stdio config (command npx, args ["-y", "tavily-mcp"], TAVILY_API_KEY in env), and call get_tools(). The returned tools bind to any LangChain model or LangGraph agent.
Do I need Node.js for a Python LangChain project?
Yes — tavily-mcp is an npm package that the adapter launches via npx as a subprocess. Node must be installed wherever the agent runs, including in your deployment container.
Why use the MCP server instead of Tavily's direct LangChain integration?
Mostly consistency: one MCP wiring pattern covers every tool you add, and you exercise the exact same server your users would run in Claude Desktop or Cursor. If you only ever need Tavily inside LangChain, their first-party integration is also a reasonable path.
Why does get_tools() fail or hang?
Run npx -y tavily-mcp manually to see the server's own output. Hangs usually mean the process printed an error instead of completing the MCP handshake; spawn errors mean Node/npx is missing from the environment's PATH.
More MCP servers for LangChain agents.
Browse Loomal's index — every listing shows the tools your agent would load.