Integrations/Knowledge
Intermediate14 min

MCP: Connect Any Tool

When MCP earns its overhead over inline tools, how to connect local and remote servers in LangChain, how to build your own server with FastMCP, and the four failure modes that trip up production deployments.

Quick Reference

  • MCP is an open protocol that standardizes how agents connect to tools, resources, and prompts via a single interface
  • Use MCP when a tool is shared across multiple agents or clients; use @tool for single-agent in-process logic
  • Connect servers via MultiServerMCPClient — tools from all servers merge into a single BaseTool list
  • Set tool_name_prefix=True when connecting multiple servers to prevent silent tool name overwrites
  • HTTP+SSE transport is deprecated (MCP spec 2025-03-26) — use Streamable HTTP for all new remote servers
  • FastMCP exposes any Python function as an MCP tool with a single @mcp.tool() decorator
  • Build the server once; use it from LangChain, Claude Desktop, Cursor, and VS Code Copilot without modification

When to Use MCP (and When Not To)

MCP adds a transport layer between your agent and its tools. That layer enables sharing, isolation, and cross-cutting logic — but it has a real cost. Before building an MCP server, verify that cost is worth paying.

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

CriterionMCP server@tool decorator
ClientsAny MCP-compatible client (LangChain, Claude Desktop, Cursor, cron jobs)One LangChain/LangGraph agent only
Call overheadstdio: subprocess IPC per call; Streamable HTTP: full HTTP round tripNone — in-process function call
Process isolationYes — subprocess or remote serviceNo — runs in-process with the agent
InterceptorsAuth, retry, rate-limiting via tool_interceptorsManual wrapper per tool
State/Store accessCannot read LangGraph State or Store directlyDirect access
Best forShared internal APIs, third-party services, multi-client toolsAgent-specific logic, State-aware tools
The MCP threshold

If only one agent uses a tool and it doesn't need process isolation, @tool is faster and simpler. If the same tool will serve two or more agents, clients, or teams — build the MCP server. The setup cost pays off quickly when the tool has more than one consumer.