Exa MCP server in LangChain web search your agents can call.
Connect Exa's hosted MCP endpoint to a LangChain agent over streamable HTTP with langchain-mcp-adapters — no subprocess, no Node dependency.
Production LangChain agents need a search tool more than almost anything else — without one, every question about the current state of the world gets answered from training data. Exa is built for exactly this caller: an AI-native search engine with crawling and code-context retrieval, whose MCP server (github.com/exa-labs/exa-mcp-server, 4.6k stars) runs hosted at Exa's endpoint.
Because the server is remote, the LangChain integration is pure HTTP — cleaner for deployment than stdio servers, since your containers don't need Node installed. langchain-mcp-adapters handles the protocol.
Search, crawl, and code-context as agent tools
Loaded into an agent, Exa's tools cover three patterns: answering with current web results, fetching and reading a specific page, and retrieving real-world code examples for an API — useful when your agent generates or reviews code. As of mid-2026 those are the hosted endpoint's tool families; Exa's live listing on the Loomal marketplace at https://loomal.ai/marketplace/exa shows the probed list.
Each call is metered against your Exa API key, so an agent loop that searches aggressively has a real cost — bound your iterations.
Connect over streamable HTTP
Install langchain-mcp-adapters, get a key from Exa's dashboard, and declare the server with the streamable_http transport. Keep the key in an environment variable rather than the source:
import os
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
client = MultiServerMCPClient({
"exa": {
"transport": "streamable_http",
"url": f"https://mcp.exa.ai/mcp?exaApiKey={os.environ['EXA_API_KEY']}",
}
})
tools = await client.get_tools()
agent = create_react_agent("anthropic:claude-sonnet-4-5", tools)Run a grounded query
Invoke the agent with something that can't be answered from memory — a price, a release date from this month, the current text of a docs page — and inspect the message trace for an Exa tool call and its returned results. If the model answers without searching, add a system-prompt rule that time-sensitive or factual claims must be grounded in a search first.
Troubleshooting in LangChain
Connection failures here are HTTP problems, not process problems. A failure during get_tools() means the handshake didn't complete: print the URL you actually built (a missing EXA_API_KEY env var produces a KeyError or an empty parameter, depending on how you interpolate) and confirm outbound HTTPS from your runtime — locked-down deployment environments commonly block it.
Tools that load but error at call time indicate the key is invalid or out of credits; the tool's error payload comes back in the agent trace. And as with any adapter usage, get_tools() is a coroutine — scripts need asyncio.run() around the async entry point or the client never connects at all.
FAQ
How do I connect Exa to LangChain?
Install langchain-mcp-adapters and create a MultiServerMCPClient with transport streamable_http and the URL https://mcp.exa.ai/mcp?exaApiKey=YOUR_KEY. Call get_tools() and pass the result to your agent — there's no config file or local server process.
Is this better than using an Exa SDK integration directly?
MCP gives you Exa's maintained tool definitions and makes the integration portable across MCP-speaking frameworks, while a direct SDK call gives finer control over parameters. For agents that just need search-as-a-tool, the MCP route is less code to own.
How should I handle the API key in production?
Inject it as an environment variable or from your secrets manager and interpolate it into the URL at startup, as in the example. Avoid hardcoding it — the URL appears in logs more easily than a header would, so also consider scrubbing request URLs from your log pipeline.
What does heavy agent search usage cost?
Exa meters API usage under its own pricing, and an unbounded agent loop can issue many searches per task. Cap tool iterations, cache repeated queries where you can, and watch the consumption graph in Exa's dashboard.
More MCP servers for LangChain agents.
Find tools your agents can discover, call, and pay for.