MCP in Production: LangChain Integration Patterns
When to use MCP vs direct tools, multi-server orchestration, interceptor composition for production, failure handling, and testing patterns for LangChain agents.
Quick Reference
- →pip install langchain-mcp-adapters fastmcp
- →MultiServerMCPClient — connect to multiple MCP servers (stdio or streamable-http)
- →client.get_tools() → pass directly to create_agent
- →prefix_tool_name_with_server_name=True — namespace tools to avoid conflicts across servers
- →throw_on_load_error=False — agent starts even if one MCP server is unavailable
- →Interceptors compose in onion order: first in list = outermost layer
- →Use client.session() for stateful servers that maintain context across calls
- →Elicitation: server can call ctx.elicit() to request mid-execution user input
When to Use MCP (and When Not To)
MCP adds ~10–50ms per tool call (JSON-RPC serialization + subprocess or HTTP transport). That overhead is only justified when you get something back for it. The decision is not 'should I use MCP?' but rather 'which of my tools are worth the indirection?'
MCP adds ~10–50ms per call — only justified when sharing, isolation, or interceptors are needed
| Approach | Setup Cost | Latency | Reusability | When to Pick It |
|---|---|---|---|---|
| MCP Server | High — build + deploy a server | +10–50ms/call | Any MCP client (Claude, LangChain, Cursor, etc.) | Shared tools, process isolation, cross-team reuse |
| Direct LangChain @tool | Low — decorate a function | Negligible | One agent only | Agent-specific logic, needs direct State/Store access |
| LangGraph ToolNode | Medium — define node + edges | Negligible | One graph only | Tool calls that route graph execution, need graph control |
If your tool will be called by only one agent and needs direct access to LangGraph State or Store, skip MCP — use a @tool decorator. If the tool will serve multiple agents, needs auth/retry/logging middleware, or runs in a different process for isolation, wrap it in MCP. The overhead pays for itself in reuse and operability.