LangChain v1.0Welcome to the new LangChain documentation! If you encounter any issues or have feedback, please open an issue so we can improve. Archived v0 documentation can be found here.See the release notes and migration guide for a complete list of changes and instructions on how to upgrade your code.
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.
For stateful servers that maintain context between tool calls, use client.session() to create a persistent ClientSession.
Using MCP ClientSession for stateful tool usage
Copy
from langchain_mcp_adapters.tools import load_mcp_toolsclient = MultiServerMCPClient({...})async with client.session("math") as session: tools = await load_mcp_tools(session)