LangChainAdapter converts MCP tools into LangChain’s DynamicStructuredTool format.
Installation
Usage
Configuration
TheLangChainAdapter supports simplified error messages, which can be useful for LLMs to better understand failures:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
🎉 v2.0.0 is out! Please note that the API may contain breaking changes. See the migration guide and changelog for details.
Use LangChainAdapter to convert MCP tools into DynamicStructuredTool instances for LangChain agents, with optional simplified error messages for LLMs.
LangChainAdapter converts MCP tools into LangChain’s DynamicStructuredTool format.
npm install @mcp-ts/sdk @langchain/core zod
import { MultiSessionClient } from '@mcp-ts/sdk/server';
import { LangChainAdapter } from '@mcp-ts/sdk/adapters/langchain';
const client = new MultiSessionClient('user_123');
await client.connect();
const adapter = new LangChainAdapter(client);
const tools = await adapter.getTools();
// Use with LangChain agent
const agent = createReactAgent({
llm,
tools,
// ...
});
LangChainAdapter supports simplified error messages, which can be useful for LLMs to better understand failures:
const adapter = new LangChainAdapter(client, {
simplifyErrors: true // Returns error.message instead of full error object
});
Was this page helpful?
