MCP HubMCP Hub
isaacwasserman

mcp-langchain-ts-client

by: isaacwasserman

LangChain.js client for Model Context Protocol.

28created 16/12/2024
Visit
LangChain
JavaScript

📌Overview

Purpose: The framework provides a client for integrating the Model Context Protocol with LangChain.js, facilitating efficient management of model interactions in JavaScript and TypeScript environments.

Overview: The mcp-langchain-ts-client is a JavaScript/TypeScript implementation of the Model Context Protocol, enabling seamless integration with LangChain.js. It serves as a bridge between the two APIs, allowing developers to utilize advanced language models in their applications effectively.

Key Features:

  • MCPToolkit Initialization: Initializes a toolkit that prepares the environment for using the Model Context Protocol, ensuring quick setup for developers.

  • LangChain.js Compatibility: Extracts tools that are compatible with LangChain.js, allowing for effortless integration of various language models and agents into applications.


mcp-langchain-ts-client

A LangChain.js client for Model Context Protocol.

This is a port of rectalogic/langchain-mcp to the JS/TS LangChain and MCP APIs.

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