LangChain MCP Client

v1.0.0Developer Toolsstable

LangChain.js client for Model Context Protocol.

mcp-langchain-ts-clientmcpai-integration
Share:
35
Stars
0
Downloads
0
Weekly
0/5

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

Implement MCP protocol in LangChain.js applications.
Connect LangChain agents to MCP servers.
Build AI applications with MCP integration.
isaacwasserman

Maintainer

LicenseMIT
Languagetypescript
Versionv1.0.0
UpdatedFeb 5, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

NPM

npx -y mcp-langchain-ts-client

Manual Installation

npx -y mcp-langchain-ts-client

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 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)
1

Install the mcp-langchain-ts-client package

Add the package to your Node.js project using npm.

npm install mcp-langchain-ts-client
2

Import 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']
};
3

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;
4

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 });
5

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.

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": { "mcp-langchain-ts-client": { "command": "npx", "args": ["-y", "mcp-langchain-ts-client"] } } }

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

Read the full setup guide →

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.

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