@langchain/mcp-adapters library.
Quickstart
Install the@langchain/mcp-adapters library:
@langchain/mcp-adapters enables agents to use tools defined across one or more MCP servers.
MultiServerMCPClient is stateless by default. Each tool invocation creates a fresh MCP ClientSession, executes the tool, and then cleans up. See the stateful sessions section for more details.Accessing multiple MCP servers
Custom servers
To create your own MCP servers, you can use the@modelcontextprotocol/sdk library. This library provides a simple way to define tools and run them as servers.
Math server (stdio transport)
Weather server (SSE transport)
Transports
MCP supports different transport mechanisms for client-server communication.HTTP
Thehttp transport (also referred to as streamable-http) uses HTTP requests for client-server communication. See the MCP HTTP transport specification for more details.
Passing headers
Authentication
stdio
Client launches server as a subprocess and communicates via standard input/output. Best for local tools and simple setups.Unlike HTTP transports,
stdio connections are inherently stateful—the subprocess persists for the lifetime of the client connection. However, when using MultiServerMCPClient without explicit session management, each tool call still creates a new session. See stateful sessions for managing persistent connections.Core features
Tools
Tools allow MCP servers to expose executable functions that LLMs can invoke to perform actions—such as querying databases, calling APIs, or interacting with external systems. LangChain converts MCP tools into LangChain tools, making them directly usable in any LangChain agent or workflow.Loading tools
Useclient.get_tools() to retrieve tools from MCP servers and pass them to your agent: