mcp-langchain-ts-client

The mcp-langchain-ts-client repository provides a LangChain.js client for the Model Context Protocol, porting the original Python implementation to JavaScript/TypeScript, enabling the use of MCP tools within LangChain.js applications.

32
1

mcp-langchain-ts-client

A LangChain.js client designed for seamless integration with the Model Context Protocol (MCP).

This project is a JavaScript/TypeScript adaptation of the original rectalogic/langchain-mcp, aligning it with the LangChain.js and MCP APIs. It enables developers to leverage the power of MCP within their LangChain.js applications.

Installation

npm install mcp-langchain-ts-client

Usage

const serverParams = {
  command: "npx",
  args: [
    "-y",
    "@modelcontextprotocol/server-everything"
  ]
}

// Initialize the toolkit
const toolkit = new MCPToolkit(serverParams);
await toolkit.initialize();

// Extract LangChain.js compatible tools
const tools = toolkit.tools;

// Use the tools
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 });

Repository

IS
isaacwasserman

isaacwasserman/mcp-langchain-ts-client

Created

December 16, 2024

Updated

March 26, 2025

Language

TypeScript

Category

AI