# langchain-mcp-adapters

> Make Anthropic Model Context Protocol (MCP) tools compatible with LangChain and LangGraph agents.

- **URL**: https://www.freshcrate.ai/projects/langchain-mcp-adapters
- **Author**: pypi
- **Category**: MCP Servers
- **Latest version**: `0.2.2` (2026-04-21)
- **License**: Unknown
- **Source**: https://www.github.com/langchain-ai/langchain-mcp-adapters
- **Homepage**: https://pypi.org/project/langchain-mcp-adapters/
- **Language**: Python
- **GitHub**: 3,495 stars, 414 forks
- **Registry**: pypi (`langchain-mcp-adapters`)
- **Tags**: `pypi`

## Description

# LangChain MCP Adapters

This library provides a lightweight wrapper that makes [Anthropic Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) tools compatible with [LangChain](https://github.com/langchain-ai/langchain) and [LangGraph](https://github.com/langchain-ai/langgraph).

![MCP](static/img/mcp.png)

> [!note]
> A JavaScript/TypeScript version of this library is also available at [langchainjs](https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-mcp-adapters/).

## Features

- 🛠️ Convert MCP tools into [LangChain tools](https://python.langchain.com/docs/concepts/tools/) that can be used with [LangGraph](https://github.com/langchain-ai/langgraph) agents
- 📦 A client implementation that allows you to connect to multiple MCP servers and load tools from them

## Installation

```bash
pip install langchain-mcp-adapters
```

## Quickstart

Here is a simple example of using the MCP tools with a LangGraph agent.

```bash
pip install langchain-mcp-adapters langgraph "langchain[openai]"

export OPENAI_API_KEY=<your_api_key>
```

### Server

First, let's create an MCP server that can add and multiply numbers.

```python
# math_server.py
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("Math")

@mcp.tool()
def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b

@mcp.tool()
def multiply(a: int, b: int) -> int:
    """Multiply two numbers"""
    return a * b

if __name__ == "__main__":
    mcp.run(transport="stdio")
```

### Client

```python
# Create server parameters for stdio connection
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

from langchain_mcp_adapters.tools import load_mcp_tools
from langchain.agents import create_agent

server_params = StdioServerParameters(
    command="python",
    # Make sure to update to the full absolute path to your math_server.py file
    args=["/path/to/math_server.py"],
)

async with stdio_client(server_params) as (read, write):
    async with ClientSession(read, write) as session:
        # Initialize the connection
        await session.initialize()

        # Get tools
        tools = await load_mcp_tools(session)

        # Create and run the agent
        agent = create_agent("openai:gpt-4.1", tools)
        agent_response = await agent.ainvoke({"messages": "what's (3 + 5) x 12?"})
```

## Multiple MCP Servers

The library also allows you to connect to multiple MCP servers and load tools from them:

### Server

```python
# math_server.py
...

# weather_server.py
from typing import List
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("Weather")

@mcp.tool()
async def get_weather(location: str) -> str:
    """Get weather for location."""
    return "It's always sunny in New York"

if __name__ == "__main__":
    mcp.run(transport="http")
```

```bash
python weather_server.py
```

### Client

```python
from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain.agents import create_agent

client = MultiServerMCPClient(
    {
        "math": {
            "command": "python",
            # Make sure to update to the full absolute path to your math_server.py file
            "args": ["/path/to/math_server.py"],
            "transport": "stdio",
        },
        "weather": {
            # Make sure you start your weather server on port 8000
            "url": "http://localhost:8000/mcp",
            "transport": "http",
        }
    }
)
tools = await client.get_tools()
agent = create_agent("openai:gpt-4.1", tools)
math_response = await agent.ainvoke({"messages": "what's (3 + 5) x 12?"})
weather_response = await agent.ainvoke({"messages": "what is the weather in nyc?"})
```

> [!note]
> Example above will start a new MCP `ClientSession` for each tool invocation. If you would like to explicitly start a session for a given server, you can do:
>
> ```python
> from langchain_mcp_adapters.tools import load_mcp_tools
>
> client = MultiServerMCPClient({...})
> async with client.session("math") as session:
>     tools = await load_mcp_tools(session)
> ```

## Streamable HTTP

MCP now supports [streamable HTTP](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http) transport.

To start an [example](examples/servers/streamable-http-stateless/) streamable HTTP server, run the following:

```bash
cd examples/servers/streamable-http-stateless/
uv run mcp-simple-streamablehttp-stateless --port 3000
```

Alternatively, you can use FastMCP directly (as in the examples above).

To use it with Python MCP SDK `streamablehttp_client`:

```python
# Use server from examples/servers/streamable-http-stateless/

from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

from langchain.agents import create_agent
from langchain_mcp_adapters.tools import load_mcp_tools

async with streamablehttp_client("http://localhost:3000/mcp") as (read, write, _):
    async with ClientSession(read, write) as s

## Recent releases

| Version | Date | Urgency | Changes |
| --- | --- | --- | --- |
| `0.2.2` | 2026-04-21 | Low | Imported from PyPI (0.2.2) |
| `langchain-mcp-adapters==0.2.2` | 2026-03-16 | Low | ## What's Changed * fix: runtime needs annotation as injected arg by @sydney-runkle in https://github.com/langchain-ai/langchain-mcp-adapters/pull/407 * build(deps): bump actions/download-artifact from 6 to 7 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/396 * build(deps): bump actions/upload-artifact from 5 to 6 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/395 * chore: pin ncipollo/release-action to v1.20.0 by @jkennedyv |
| `langchain-mcp-adapters==0.2.2` | 2026-03-16 | Low | ## What's Changed * fix: runtime needs annotation as injected arg by @sydney-runkle in https://github.com/langchain-ai/langchain-mcp-adapters/pull/407 * build(deps): bump actions/download-artifact from 6 to 7 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/396 * build(deps): bump actions/upload-artifact from 5 to 6 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/395 * chore: pin ncipollo/release-action to v1.20.0 by @jkennedyv |
| `langchain-mcp-adapters==0.2.2` | 2026-03-16 | Low | ## What's Changed * fix: runtime needs annotation as injected arg by @sydney-runkle in https://github.com/langchain-ai/langchain-mcp-adapters/pull/407 * build(deps): bump actions/download-artifact from 6 to 7 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/396 * build(deps): bump actions/upload-artifact from 5 to 6 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/395 * chore: pin ncipollo/release-action to v1.20.0 by @jkennedyv |
| `langchain-mcp-adapters==0.2.2` | 2026-03-16 | Low | ## What's Changed * fix: runtime needs annotation as injected arg by @sydney-runkle in https://github.com/langchain-ai/langchain-mcp-adapters/pull/407 * build(deps): bump actions/download-artifact from 6 to 7 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/396 * build(deps): bump actions/upload-artifact from 5 to 6 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/395 * chore: pin ncipollo/release-action to v1.20.0 by @jkennedyv |
| `langchain-mcp-adapters==0.2.2` | 2026-03-16 | Low | ## What's Changed * fix: runtime needs annotation as injected arg by @sydney-runkle in https://github.com/langchain-ai/langchain-mcp-adapters/pull/407 * build(deps): bump actions/download-artifact from 6 to 7 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/396 * build(deps): bump actions/upload-artifact from 5 to 6 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/395 * chore: pin ncipollo/release-action to v1.20.0 by @jkennedyv |
| `langchain-mcp-adapters==0.2.2` | 2026-03-16 | Low | ## What's Changed * fix: runtime needs annotation as injected arg by @sydney-runkle in https://github.com/langchain-ai/langchain-mcp-adapters/pull/407 * build(deps): bump actions/download-artifact from 6 to 7 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/396 * build(deps): bump actions/upload-artifact from 5 to 6 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/395 * chore: pin ncipollo/release-action to v1.20.0 by @jkennedyv |
| `langchain-mcp-adapters==0.2.2` | 2026-03-16 | Low | ## What's Changed * fix: runtime needs annotation as injected arg by @sydney-runkle in https://github.com/langchain-ai/langchain-mcp-adapters/pull/407 * build(deps): bump actions/download-artifact from 6 to 7 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/396 * build(deps): bump actions/upload-artifact from 5 to 6 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/395 * chore: pin ncipollo/release-action to v1.20.0 by @jkennedyv |
| `langchain-mcp-adapters==0.2.2` | 2026-03-16 | Low | ## What's Changed * fix: runtime needs annotation as injected arg by @sydney-runkle in https://github.com/langchain-ai/langchain-mcp-adapters/pull/407 * build(deps): bump actions/download-artifact from 6 to 7 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/396 * build(deps): bump actions/upload-artifact from 5 to 6 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/395 * chore: pin ncipollo/release-action to v1.20.0 by @jkennedyv |
| `langchain-mcp-adapters==0.2.2` | 2026-03-16 | Low | ## What's Changed * fix: runtime needs annotation as injected arg by @sydney-runkle in https://github.com/langchain-ai/langchain-mcp-adapters/pull/407 * build(deps): bump actions/download-artifact from 6 to 7 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/396 * build(deps): bump actions/upload-artifact from 5 to 6 by @dependabot[bot] in https://github.com/langchain-ai/langchain-mcp-adapters/pull/395 * chore: pin ncipollo/release-action to v1.20.0 by @jkennedyv |

## Citation

- HTML: https://www.freshcrate.ai/projects/langchain-mcp-adapters
- Markdown: https://www.freshcrate.ai/projects/langchain-mcp-adapters.md
- Dependencies JSON: https://www.freshcrate.ai/api/projects/langchain-mcp-adapters/deps

_Generated by freshcrate.ai. Indexes pypi releases for AI-agent ecosystem packages._
