Skip to main content
Model Context Protocol (MCP) is an open protocol that standardizes how applications provide tools and context to LLMs. LangChain agents can use tools defined on MCP servers using the langchain-mcp-adapters library.

Install

Install the langchain-mcp-adapters library to use MCP tools in LangGraph:

Transport types

MCP supports different transport mechanisms for client-server communication:
  • stdio – Client launches server as a subprocess and communicates via standard input/output. Best for local tools and simple setups.
  • Streamable HTTP – Server runs as an independent process handling HTTP requests. Supports remote connections and multiple clients.
  • Server-Sent Events (SSE) – a variant of streamable HTTP optimized for real-time streaming communication.

Use MCP tools

langchain-mcp-adapters enables agents to use tools defined across one or more MCP server.
Accessing multiple MCP servers
MultiServerMCPClient is stateless by default. Each tool invocation creates a fresh MCP ClientSession, executes the tool, and then cleans up.

Custom MCP servers

To create your own MCP servers, you can use the mcp library. This library provides a simple way to define tools and run them as servers.
Use the following reference implementations to test your agent with MCP tool servers.
Math server (stdio transport)
Weather server (streamable HTTP transport)

Stateful tool usage

For stateful servers that maintain context between tool calls, use client.session() to create a persistent ClientSession.
Using MCP ClientSession for stateful tool usage

Additional resources


Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.