LangChain MCP
Model Context Protocol tool support for LangChain
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
Maintainer
Works with
Installation
NPM
npx -y langchain-mcpManual Installation
npx -y langchain-mcpConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
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)
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-groqCreate 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 belowInitialize 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()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.
LangChain MCP Alternatives — Similar Developer Tools Servers
Looking for alternatives to LangChain MCP? Here are other popular developer tools servers you can use with Claude, Cursor, and VS Code.
Ecc
★ 188.2kThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Javaguide
★ 155.8kJava 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发
Gemini CLI
★ 104.5kA secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
Awesome MCP Servers
★ 87.3k⭐ Curated list of Model Context Protocol (MCP) servers - tools that extend Claude Desktop, Cursor, Windsurf, and other MCP clients with custom capabilities.
MCP Servers
★ 86.0kModel Context Protocol Servers
CC Switch
★ 77.5kA cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
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.
Set Up LangChain MCP in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
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.