Get the FREE Ultimate OpenClaw Setup Guide β†’

langchain -adapters

LangChain πŸ”Œ MCP

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio langchain-ai-langchain-mcp-adapters python -m langchain_mcp_adapters

How to use

LangChain MCP Adapters is a Python library that provides tooling to connect to MCP servers and load MCP-based tools as LangChain tools. It includes a client (MultiServerMCPClient) that can connect to one or more MCP servers and expose their tools to LangChain agents, enabling you to orchestrate tools from multiple MCP servers in a single agent workflow. The library also includes utilities to load tools from a connected MCP session and to create LangChain agents that can invoke those tools via the MCP protocol. Use cases include building agents that can perform tasks by composing measurement or computation tools exposed by MCP servers, such as math computations, data retrieval, or other domain-specific actions, all served through a consistent LangChain interface.

Typical workflow: start one or more MCP servers that expose tools, instantiate MultiServerMCPClient with the server configurations, obtain the loaded tools with get_tools(), and then create and run a LangChain agent (e.g., with create_agent) that can invoke those tools via natural language prompts.

How to install

Prerequisites:

  • Python 3.8+ (or as specified by your environment)
  • pip (or your preferred Python package manager)

Installation steps:

  1. Create and activate a Python virtual environment (optional but recommended):

    python -m venv venv source venv/bin/activate # Linux/macOS venv\Scripts\activate # Windows

  2. Install the LangChain MCP Adapters package from PyPI:

    pip install langchain-mcp-adapters

  3. If you plan to run additional MCP-related examples, ensure you have any other required tooling installed (e.g., LangChain, LangGraph, OpenAI packages) as described in their respective docs.

  4. Verify installation by importing in Python:

    python -c "import langchain_mcp_adapters; print('langchain_mcp_adapters loaded')"

Additional notes

Notes and tips:

  • This library focuses on acting as a client layer and adapter between MCP servers and LangChain/LangGraph tooling. It does not itself host an MCP server; you will need to run MCP servers separately and point the client at them.
  • Supported transports in examples include stdio, HTTP, and streamable HTTP; the MultiServerMCPClient can configure servers with transport and connection details (e.g., command+args for local Python servers or URL for HTTP endpoints).
  • When using multiple servers, you can load tools from each server and aggregate them into a single toolset for a LangChain agent.
  • You can explicitly manage sessions for a given server using the provided session methods if you want to reuse connections across multiple tool invocations.
  • If you encounter transport-related issues, verify network accessibility (URLs/ports) and ensure servers are running and reachable.

Related MCP Servers

Sponsor this space

Reach thousands of developers β†—