Get the FREE Ultimate OpenClaw Setup Guide →

mcp-langchain-ts-client

LangChain.js client for Model Context Protocol.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio isaacwasserman-mcp-langchain-ts-client npx -y @modelcontextprotocol/server-everything

How to use

The mcp-langchain-ts-client provides a LangChain.js compatible client for interacting with Model Context Protocol (MCP). It leverages the MCPToolkit to boot a server that exposes MCP-backed tools which can be consumed by LangChain.js agents and tool-exports. The setup shown uses npx to fetch and run the MCP server package on demand, enabling access to a collection of tools through the toolkit’s interface. Once initialized, you can retrieve the LangChain-compatible tools and integrate them into a LangChain agent (for example, by using LangGraph’s prebuilt agents) to build autonomous or human-in-the-loop workflows that leverage MCP reasoning and data context.

To use it in your codebase, initialize the toolkit with the server parameters, extract toolkit.tools to obtain the MCP-backed tools, and then wire those tools into a LangChain.js agent or workflow. In the example, a ChatAnthropic LLM is prepared alongside a LangChain agent builder (createReactAgent) that consumes the MCP tools. This enables you to issue natural language prompts that leverage the MCP tools for context-aware responses, planning, and retrieval. The integration design is compatible with LangChain.js tool formats, so tools from the MCP server can be used alongside other LangChain tools in your pipeline.

How to install

Prerequisites:

  • Node.js and npm installed on your system
  • Basic familiarity with npm or npx to run packages on the fly

Installation steps:

  1. Ensure Node.js and npm are installed. Check versions:
node -v
npm -v
  1. Install and run the MCP LangChain TS Client via npx as shown in the usage example (no global install required):
npx -y @modelcontextprotocol/server-everything
  1. Alternatively, install the client package locally in your project if you want to manage it as a dependency:
npm install mcp-langchain-ts-client
  1. Initialize the toolkit in your code with the server parameters (see usage). The server is started by passing the command and arguments to the MCPToolkit (as shown in the README usage).

  2. If you maintain a local dev environment, you can create a small script to start the MCP server with the preferred configuration and then import the toolkit in your LangChain integration code.

Additional notes

Tips and caveats:

  • The server is started via npx with the package @modelcontextprotocol/server-everything; ensure you have network access so npm can fetch the package.
  • If you need to customize environment variables for the MCP server (e.g., endpoints, authentication), you can pass them to your runtime environment where the toolkit initializes the server process.
  • The MCP tools exposed by the server integrate into LangChain.js as standard tools; you can combine them with other LangChain tools and LLMs in the same workflow.
  • If you encounter compatibility issues, verify that your LangChain.js version matches the MCP tooling expectations and that the MCP server package version is compatible with your environment.
  • When deploying, consider pinning the MCP server package version to avoid breaking changes from upstream updates.

Related MCP Servers

Sponsor this space

Reach thousands of developers