LangChain/Advanced
Advanced14 min

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?'

Need a new tool in your agent?Start here to pick the right approachWill this tool be used bymultiple agents or clients?YesUse MCPshared serverNoDoes it need process isolationor run in a different runtime?YesUse MCPisolated procNoNeed cross-cutting logic (auth,retry, rate-limit) via interceptors?YesUse MCP+ interceptorsNoDoes it need direct LangGraphState / Store access?YesDirect Tool@tool decoratorNoDirect LangChain tool — simpler, lower latency

MCP adds ~10–50ms per call — only justified when sharing, isolation, or interceptors are needed

ApproachSetup CostLatencyReusabilityWhen to Pick It
MCP ServerHigh — build + deploy a server+10–50ms/callAny MCP client (Claude, LangChain, Cursor, etc.)Shared tools, process isolation, cross-team reuse
Direct LangChain @toolLow — decorate a functionNegligibleOne agent onlyAgent-specific logic, needs direct State/Store access
LangGraph ToolNodeMedium — define node + edgesNegligibleOne graph onlyTool calls that route graph execution, need graph control
The MCP threshold

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.