LangChain MCP

v1.0.0Developer Toolsstable

Model Context Protocol tool support for LangChain

langchainmcpai-integration
Share:
205
Stars
0
Downloads
0
Weekly
0/5

What is LangChain MCP?

LangChain MCP is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to model context protocol tool support for langchain

Model Context Protocol tool support for LangChain

This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • Model Context Protocol tool support for LangChain

Use Cases

Use MCP tools within LangChain agents and chains.
Integrate MCP capabilities into LangChain workflows.
rectalogic

Maintainer

LicenseMIT
Languagepython
Versionv1.0.0
UpdatedMar 31, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

NPM

npx -y langchain-mcp

Manual Installation

npx -y langchain-mcp

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use LangChain MCP

langchain-mcp is a Python adapter package that makes any MCP server's tools available as standard LangChain BaseTool objects, enabling LangChain agents and chains to call MCP tools without any custom glue code. You instantiate an MCPToolkit with an active MCP ClientSession, call initialize(), and receive a list of LangChain-compatible tools that can be passed directly to agents, ReAct loops, or LCEL chains. This is the canonical way to combine the broad MCP server ecosystem with LangChain's agent orchestration capabilities.

Prerequisites

  • Python 3.10 or later
  • uv package manager or pip for installing Python dependencies
  • An MCP server to connect to (e.g., the Filesystem MCP server or any other MCP-compatible server)
  • LangChain (langchain-core) installed in your Python environment
  • An LLM API key for whichever model your LangChain agent will use (e.g., GROQ_API_KEY for Groq/Llama)
1

Install langchain-mcp and dependencies

Install the langchain-mcp package along with langchain-core and your chosen LLM provider package. The package is available on PyPI.

pip install langchain-mcp langchain-core
# For the Groq demo model:
pip install langchain-groq
2

Create an MCP client session

Use the MCP Python SDK to create a ClientSession connected to any MCP server (stdio or HTTP). This session is passed to MCPToolkit.

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

server_params = StdioServerParameters(
    command="npx",
    args=["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
)

async with stdio_client(server_params) as (read, write):
    async with ClientSession(read, write) as session:
        await session.initialize()
        # pass session to MCPToolkit below
3

Initialize MCPToolkit and get tools

Wrap the session in an MCPToolkit, call initialize(), and retrieve BaseTool objects ready for use in any LangChain agent or chain.

import langchain_mcp

toolkit = langchain_mcp.MCPToolkit(session)
await toolkit.initialize()
tools = toolkit.get_tools()
4

Pass tools to a LangChain agent

Bind the retrieved tools to your chosen LLM and run a LangChain agent as you normally would. The MCP tools are indistinguishable from any other LangChain tool.

from langchain_groq import ChatGroq
from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain_core.prompts import ChatPromptTemplate

llm = ChatGroq(model="llama-3.1-8b-instant")
prompt = ChatPromptTemplate.from_messages([("system", "You are a helpful assistant."), ("placeholder", "{agent_scratchpad}"), ("human", "{input}")])
agent = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)
result = await executor.ainvoke({"input": "Read and summarize the file ./LICENSE"})

LangChain MCP Examples

Client configuration

Python snippet showing the minimal pattern to get LangChain tools from any MCP server using MCPToolkit.

{
  "note": "langchain-mcp is a Python library, not a stdio MCP server. Configure MCP servers separately and connect to them via MCP ClientSession.",
  "example_env": {
    "GROQ_API_KEY": "your-groq-api-key"
  }
}

Prompts to try

Example agent invocations once tools are connected via MCPToolkit.

- "Read and summarize the file ./README.md"
- "List all files in the /tmp directory and tell me their sizes."
- "Search for the word 'TODO' in all Python files under ./src."
- "What MCP tools are available and what can each one do?"

Troubleshooting LangChain MCP

MCPToolkit.initialize() raises a connection error

Confirm the MCP server process starts successfully by running it manually in your terminal. Check that the command and args in StdioServerParameters are correct and that the target MCP server package is installed.

Tools list is empty after toolkit.initialize()

Verify that your MCP server actually exposes tools (not just resources). Some MCP servers only expose resources. Call session.list_tools() directly to see what the server advertises.

Agent fails with 'API key not found' errors

langchain-mcp does not manage LLM credentials. Set the appropriate environment variable for your LLM provider (e.g., GROQ_API_KEY, OPENAI_API_KEY) before running your agent script.

Frequently Asked Questions about LangChain MCP

What is LangChain MCP?

LangChain MCP is a Model Context Protocol (MCP) server that model context protocol tool support for langchain It connects AI assistants to external tools and data sources through a standardized interface.

How do I install LangChain MCP?

Install via npm with the command: npx -y langchain-mcp. Then add the server configuration to your AI client's JSON config file (e.g., claude_desktop_config.json or .cursor/mcp.json).

Which AI clients work with LangChain MCP?

LangChain MCP works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is LangChain MCP free to use?

Yes, LangChain MCP is open source and available under the MIT license. You can use it freely in both personal and commercial projects.

Browse More Developer Tools MCP Servers

Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "langchain": { "command": "npx", "args": ["-y", "langchain-mcp"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use LangChain MCP?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides