---
title: How to use MCP servers with LangChain
description: Install langchain[mcp], open the server with MCPAdapter, call list_tools() and pass the tools to create_agent. Auth, several servers, filters and migration.
canonical: https://mcp1.com/blog/mcp-servers-langchain
last-updated: 2026-12-05
---

# How to use MCP servers with LangChain

Install langchain\[mcp\], open the server with MCPAdapter, call list\_tools() and pass the tools to create\_agent. Auth, several servers, filters and migration.

![](https://avatars.githubusercontent.com/u/1297371?s=96&v=4)Eldad FuxFounder and CEO, Appwrite

 agent.py

async with MCPAdapter(Client(url, auth=token)) as mcp:
  tools = await mcp.list_tools()
  agent = create_agent(model, tools)

list\_issues, get\_issue, ...tools loaded

 agent.py

async with MCPAdapter(Client(url, auth=token)) as mcp:
  tools = await mcp.list_tools()
  agent = create_agent(model, tools)

list\_issues, get\_issue, ...tools loaded

To use a remote MCP server with LangChain, install `langchain[mcp]`, wrap the server in `MCPAdapter` from `langchain.mcp`, call `list_tools()` and pass the result to `create_agent`. Send a token with a FastMCP `Client` and its `auth` argument. The agent `create_agent` returns is a LangGraph graph, so the same tools work in LangGraph.

## How do I connect an MCP server to a LangChain agent?

Install the extra. It needs LangChain 1.4 or later, and the MCP support is marked beta, so expect a one-time warning:

Terminal

```
pip install "langchain[mcp]"
```

Then open the server, list its tools and build the agent. This one reads Linear through its read-only endpoint with a Linear API key:

agent.py

```
import asyncio, os
from fastmcp.client import Client
from langchain.agents import create_agent
from langchain.mcp import MCPAdapter

async def main():
    linear = Client("https://mcp.linear.app/mcp/readonly", auth=os.environ["LINEAR_API_KEY"])
    async with MCPAdapter(linear) as mcp:
        tools = await mcp.list_tools()
        agent = create_agent("claude-sonnet-5-5", tools)
        result = await agent.ainvoke(
            {"messages": [{"role": "user", "content": "Summarize the open issues in Checkout by priority"}]}
        )
        print(result["messages"][-1].content)

asyncio.run(main())
```

`MCPAdapter` takes one target: a URL string for a public server, a `Path` to a script it runs over stdio, an `mcpServers` config dict, or a FastMCP `Client` when you need auth, headers or a timeout. A bare string must be an http or https URL. The `auth` argument takes a token string, the literal `"oauth"` for a browser sign-in, or any `httpx.Auth`.

## What happened to langchain-mcp-adapters and MultiServerMCPClient?

The package is archived and no longer maintained, and its code moved into LangChain. Existing installs keep working, but new code should use `langchain.mcp`. The changes you will hit:

agent.py

```
# before: langchain-mcp-adapters
client = MultiServerMCPClient({
    "linear": {"transport": "http", "url": URL, "headers": {"Authorization": f"Bearer {key}"}},
})
tools = await client.get_tools()

# after: langchain.mcp
async with MCPAdapter(Client(URL, auth=key)) as mcp:
    tools = await mcp.list_tools()
```

langchain-mcp-adapterslangchain.mcp

`MultiServerMCPClient(...)`

An `mcpServers` dict or a `ClientGroup` passed to `MCPAdapter`. Drop the `transport` key; it is inferred.

`get_tools()`

`list_tools()`

`client.session(name)`

Gone. Keep the async with block open around the agent run instead.

`tool_name_prefix`

Gone. Multi-server targets always prefix names as server\_tool.

`handle_tool_errors`

Gone. A tool error comes back as a ToolMessage with status="error"; transport failures raise.

`tool_interceptors`

LangChain middleware such as @wrap\_tool\_call.

Prompts and resources

Not supported. Call get\_prompt or read\_resource on the FastMCP client.

## How do I connect several MCP servers with different credentials?

Use a `ClientGroup`, which keeps one connection per server, each with its own auth. Tool names come back prefixed with the server key, so two servers that both have a `search` tool don’t collide:

agent.py

```
from fastmcp.client import Client
from fastmcp.client.group import ClientGroup

group = ClientGroup({
    "linear": Client("https://mcp.linear.app/mcp/readonly", auth=os.environ["LINEAR_API_KEY"]),
    "sentry": Client("https://mcp.sentry.dev/mcp", auth="oauth"),
})
async with MCPAdapter(group) as mcp:
    tools = await mcp.list_tools()   # linear_list_issues, sentry_search_issues, ...
```

If every server takes a static header, an `mcpServers` dict also works: each entry takes `url` and `headers`, or `command` and `args` for a local server. More on naming in [MCP tool name collisions](https://mcp1.com/blog/mcp-tool-name-collisions).

## How do I limit which MCP tools the agent can use?

Filter the list before you build the agent. `MCPAdapter` has no filter option, and a plain list comprehension is enough. Use an allow list, so a tool the server adds next month stays out until you add it:

agent.py

```
ALLOWED = {"linear_list_issues", "linear_get_issue", "sentry_search_issues"}
tools = [t for t in await mcp.list_tools() if t.name in ALLOWED]
```

Every tool you pass costs context on each model call, so filtering helps accuracy too. See [too many MCP tools](https://mcp1.com/blog/too-many-mcp-tools).

The token is the real limit

A filter decides what the model is offered. What the server will do is set by the credential, so give agents read-only tokens or endpoints where they exist, like Linear’s `/mcp/readonly`. More in [how to make an MCP server read-only](https://mcp1.com/blog/read-only-mcp-server).

## How do I log or approve MCP tool calls in LangChain?

With agent middleware. `@wrap_tool_call` runs around every tool call, MCP or not, so it is the place to log, block or rewrite one. The MCP server and tool are in `request.tool.metadata["mcp"]`.

agent.py

```
from langchain.agents.middleware import wrap_tool_call

@wrap_tool_call
def log_mcp_calls(request, handler):
    print("calling", request.tool_call["name"], request.tool_call["args"])
    return handler(request)

agent = create_agent("claude-sonnet-5-5", tools, middleware=[log_mcp_calls])
```

For a human in the loop, LangChain’s `HumanInTheLoopMiddleware` pauses the run before chosen tools and resumes on approve or reject. It needs a checkpointer and the same `thread_id` on resume. A server that asks the user a question through MCP elicitation surfaces the same way, as a LangGraph interrupt.

## What else should I know before production?

- Sessions. By default each tool call opens its own MCP session and closes it. A server that keeps state between calls needs the `async with MCPAdapter` block held open around `agent.ainvoke`.
- Timeouts. Set `timeout` on the FastMCP `Client` for slow servers.
- Results. Structured content lands in the `ToolMessage` artifact under `structured_content`, and images become image content blocks.
- Unsupported features. Sampling and roots raise. A tool that needs them won’t work through the adapter.

## Does LangChain.js support MCP?

Yes, through `@langchain/mcp-adapters` 2.x, which has its own `MCPAdapter`. Remote servers take `url` and `headers`, or an `authProvider` for tokens that rotate. Tool names are prefixed with the server name unless you set `prefixToolNameWithServerName: false`:

agent.ts

```
import { MCPAdapter } from "@langchain/mcp-adapters";
import { createAgent } from "langchain";

const mcp = new MCPAdapter({
  servers: {
    linear: {
      url: "https://mcp.linear.app/mcp/readonly",
      headers: { Authorization: `Bearer ${process.env.LINEAR_API_KEY}` },
    },
  },
});
const agent = createAgent({ model: "claude-sonnet-5-5", tools: await mcp.listTools() });
```

## One URL and one key for every server

Each server in a `ClientGroup` brings its own token, scoping and revocation. MCP1 puts the servers behind one gateway, so the agent holds a single MCP1 API key, scoped to that gateway and optionally to some of its servers, with an expiry:

agent.py

```
gateway = Client("https://mcp1.com/mcp/<workspace>/<gateway>", auth=os.environ["MCP1_API_KEY"])
async with MCPAdapter(gateway) as mcp:
    tools = await mcp.list_tools()
```

A small gateway lists its servers’ tools directly, already namespaced as `linear__list_issues` and so on. A larger one lists MCP1’s own tools, and the agent finds the rest with `mcp1__search_tools` and runs them with `mcp1__call_tool`, so tool definitions stay small however many servers sit behind it. The key acts as the person who made it, so their groups, read-only grants and tool rules apply, and every call is recorded in the audit log. For other frameworks, see [the OpenAI Agents SDK](https://mcp1.com/blog/mcp-servers-openai-agents-sdk) and [the Claude Agent SDK](https://mcp1.com/blog/mcp-servers-claude-agent-sdk). The [docs](https://mcp1.com/docs#keys) cover keys, and the Individual plan is free to [start with](https://mcp1.com/signup).

## Common questions

### Is langchain-mcp-adapters deprecated?

Yes. The repository is archived and MCP support moved into LangChain as langchain.mcp. Install langchain\[mcp\] and replace MultiServerMCPClient with MCPAdapter.

### Does LangChain support MCP OAuth?

Yes, through FastMCP. Pass auth="oauth" to the Client and it runs discovery, dynamic client registration and a browser sign-in. Servers in production usually take a token instead.

### Can I use MCP tools in a custom LangGraph graph?

Yes. list\_tools() returns ordinary LangChain tools, so you can bind them to a model and run them in a tool node like any other tool.

### Does LangChain support MCP prompts and resources?

Not through MCPAdapter, which loads tools only. Call get\_prompt or read\_resource on the FastMCP client directly.

Give your team one URL

Create a workspace, install your servers and share a gateway with a group. Free for individuals.

[Start with MCP1](https://mcp1.com/signup)[Read the docs](https://mcp1.com/docs)

## More from the blog

[ .cursor/mcp.json"atlassian": { "url": "https://mcp.atlassian.com/v2/mcp" }atlassianConnectedHow to connect Jira MCP to CursorAdd https://mcp.atlassian.com/v2/mcp to .cursor/mcp.json and sign in to Atlassian. The Jira tools, admin controls, approvals, API tokens and fixes.![](https://avatars.githubusercontent.com/u/1297371?s=96&v=4)Eldad FuxFounder and CEO, Appwrite](https://mcp1.com/blog/jira-mcp-cursor)[ .cursor/mcp.json"figma": { "url": "https://mcp.figma.com/mcp" }figmaConnectedHow to connect Figma MCP to CursorRun /add-plugin figma or add https://mcp.figma.com/mcp to .cursor/mcp.json, then click Connect. Frame links, tools, rate limits, approvals and fixes.![](https://avatars.githubusercontent.com/u/1297371?s=96&v=4)Eldad FuxFounder and CEO, Appwrite](https://mcp1.com/blog/figma-mcp-cursor)

---

This is the markdown copy of https://mcp1.com/blog/mcp-servers-langchain. Site index for agents: https://mcp1.com/llms.txt
