LangChain MCP Client
LangChain.js client for Model Context Protocol.
What is LangChain MCP Client?
LangChain MCP Client is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to langchain.js client for model context protocol.
LangChain.js client for Model Context Protocol.
This server falls under the Developer Tools and APIs categories on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- LangChain.js client for Model Context Protocol.
Use Cases
Maintainer
Works with
Installation
NPM
npx -y mcp-langchain-ts-clientManual Installation
npx -y mcp-langchain-ts-clientConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use LangChain MCP Client
mcp-langchain-ts-client is a TypeScript/JavaScript library that bridges LangChain.js and the Model Context Protocol, enabling LangChain agents to consume tools exposed by any MCP server. It is a port of the Python 'langchain-mcp' library to the JS/TS ecosystem and works by wrapping MCP server connections as a LangChain 'MCPToolkit' that extracts tool definitions compatible with LangChain's agent framework. This makes it straightforward to build LangChain agents that can call MCP tools from servers like filesystem, browser automation, or any custom MCP server.
Prerequisites
- Node.js 18 or later
- npm or yarn package manager
- A LangChain.js project (npm install langchain @langchain/core @langchain/langgraph)
- An Anthropic or OpenAI API key for the LLM powering the agent
- An MCP server to connect to (e.g., @modelcontextprotocol/server-everything for testing)
Install the mcp-langchain-ts-client package
Add the package to your Node.js project using npm.
npm install mcp-langchain-ts-clientImport MCPToolkit and configure the MCP server connection
Import MCPToolkit from the package and define the serverParams object specifying the MCP server command and arguments. This example uses the '@modelcontextprotocol/server-everything' test server.
import { MCPToolkit } from 'mcp-langchain-ts-client';
const serverParams = {
command: 'npx',
args: ['-y', '@modelcontextprotocol/server-everything']
};Initialize the toolkit and extract LangChain tools
Create an MCPToolkit instance, call initialize() to connect to the MCP server and load its tool definitions, then extract the tools array for use with LangChain agents.
const toolkit = new MCPToolkit(serverParams);
await toolkit.initialize();
const tools = toolkit.tools;Build a LangChain ReAct agent with the MCP tools
Use the extracted tools with a LangChain agent. This example uses createReactAgent from @langchain/langgraph with Claude as the underlying LLM.
import { createReactAgent } from '@langchain/langgraph/prebuilt';
import { ChatAnthropic } from '@langchain/anthropic';
const llm = new ChatAnthropic({ model: 'claude-3-5-sonnet-20241022' });
const agent = createReactAgent({ llm, tools });Run the agent with a task
Invoke the agent with a human message. The agent will automatically select and call MCP tools as needed to complete the task.
const result = await agent.invoke({
messages: [{ role: 'human', content: 'List all available tools and describe what they do' }]
});
console.log(result.messages.at(-1).content);LangChain MCP Client Examples
Client configuration (package.json usage)
This library is used as a code dependency, not a standalone MCP server. Install it in your project and wire it up programmatically.
{
"dependencies": {
"mcp-langchain-ts-client": "latest",
"@langchain/anthropic": "latest",
"@langchain/langgraph": "latest",
"langchain": "latest"
}
}Prompts to try (agent invocations)
These are example task strings to pass to the LangChain agent's invoke() method.
- "Use the filesystem tool to list files in the current directory"
- "Search the web for the latest MCP specification updates"
- "Read the contents of README.md and summarize it"
- "What tools are available to you and which would be best for code analysis?"Troubleshooting LangChain MCP Client
MCPToolkit.initialize() hangs or times out
The MCP server process specified in serverParams must be launchable from your environment. Ensure the command (e.g., 'npx') is on your PATH and the package exists. Try running the command manually in a terminal to confirm it starts without errors.
Tools array is empty after initialization
Some MCP servers take a moment to start and register their tools. Try adding a short delay before calling toolkit.tools, or check the MCP server's own logs for initialization errors. Ensure the server actually exposes tools (not just resources or prompts).
TypeScript type errors when using extracted tools with LangChain
Ensure your LangChain packages (@langchain/core, @langchain/langgraph) are up to date. The MCPToolkit returns tools typed as LangChain StructuredTool instances, which are compatible with createReactAgent and other LangChain agent constructors from recent versions.
Frequently Asked Questions about LangChain MCP Client
What is LangChain MCP Client?
LangChain MCP Client is a Model Context Protocol (MCP) server that langchain.js client for model context protocol. It connects AI assistants to external tools and data sources through a standardized interface.
How do I install LangChain MCP Client?
Install via npm with the command: npx -y mcp-langchain-ts-client. 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 Client?
LangChain MCP Client works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is LangChain MCP Client free to use?
Yes, LangChain MCP Client is open source and available under the MIT license. You can use it freely in both personal and commercial projects.
LangChain MCP Client Alternatives — Similar Developer Tools Servers
Looking for alternatives to LangChain MCP Client? 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 Client 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 Client?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.