article
README
🚀 mcp-langchain-ts-client
这是一个用于 Model Context Protocol 的 LangChain.js 客户端,它将 rectalogic/langchain-mcp 迁移到了 JS/TS LangChain 和 MCP API。
🚀 快速开始
本项目是一个用于 Model Context Protocol 的 LangChain.js 客户端,能帮助开发者在 JS/TS 环境下使用相关功能。
📦 安装指南
使用以下命令进行安装:
npm install mcp-langchain-ts-client
💻 使用示例
基础用法
const serverParams = {
command: "npx",
args: [
"-y",
"@modelcontextprotocol/server-everything"
]
}
// 初始化工具包
const toolkit = new MCPToolkit(serverParams);
await toolkit.initialize();
// 提取 LangChain.js 兼容的工具
const tools = toolkit.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 });
微信扫一扫