@h1deya/mcp-langchain-tools v0.0.17
MCP Server To LangChain Tools Conversion Utility

This package is intended to simplify the use of MCP server tools within LangChain.
It contains a utility function convertMCPServersToLangChainTools()
that initializes specified MCP servers,
and returns LangChain Tools
that wrap all the available MCP server tools.
Installation
npm i @h1deya/mcp-langchain-toolQuick Start
convertMCPServersToLangChainTools() utility function accepts MCP server configuration
in pretty much the same format as a JS Object interpretation of the JSON format used by
Claude for Desktop
(it just needs the contents of the mcpServers property).
e.g.:
const mcpServers: MCPServersConfig = {
filesystem: {
command: 'npx',
args: [
'-y',
'@modelcontextprotocol/server-filesystem',
'/Users/username/Desktop' // path to a directory to allow access to
]
},
fetch: {
command: 'uvx',
args: [
'mcp-server-fetch'
]
}
};
const { tools, cleanup } = await convertMCPServersToLangChainTools(mcpServers);The utility functoin initializes all the MCP server connections concurrently,
and returns LangChain Tools (tools: DynamicStructuredTool[])
by gathering all the available MCP server tools,
and by wrapping them into LangChain Tools.
It also returns cleanup callback function
which is used to close all the connections to the MCP servers when finished.
The returned tools can be used with LangChain, e.g.:
const agent = createReactAgent({
llm: llmModel,
tools: tools,
checkpointSaver: new MemorySaver()
});A simple but complete usage example can be found in here
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago