
What is langchain-mcp-tools-ts
langchain-mcp-tools-ts is a server utility designed to streamline the integration of Model Context Protocol (MCP) tools with LangChain, a popular framework in the AI community. Developed by Hideya, this package simplifies the process of connecting multiple external resources and tools to LangChain applications using TypeScript. MCP is an open-source protocol that enhances the capabilities of language models by allowing them to interact seamlessly with external data sources and services such as Google Drive, Slack, Notion, and more. This integration empowers AI systems to access and utilize real-time information, making them more versatile and effective.
How to Use langchain-mcp-tools-ts
To begin using langchain-mcp-tools-ts, ensure you have Node.js version 16 or higher installed. You can install the package using npm with the following command:
npm i @h1deya/langchain-mcp-tools
Once installed, the core utility function convertMcpToLangchainTools()
can be used to initialize and convert MCP servers into LangChain-compatible tools. Define your MCP server configurations as a JavaScript object, specifying the command and arguments for each server. Here's a basic example:
const mcpServers = {
filesystem: {
command: 'npx',
args: ['-y', '@modelcontextprotocol/server-filesystem', '.']
},
fetch: {
command: 'uvx',
args: ['mcp-server-fetch']
}
};
const { tools, cleanup } = await convertMcpToLangchainTools(mcpServers);
This function initializes the specified MCP servers in parallel, gathers their available tools, and wraps them into LangChain tools. The returned tools
can be directly used with LangChain applications. Additionally, a cleanup
function is provided to close all MCP server sessions when you are finished.
Key Features of langchain-mcp-tools-ts
-
Integration with MCP: Seamlessly integrates over 1500 MCP servers with LangChain, enabling the use of a wide array of external data sources and tools.
-
Parallel Server Initialization: Efficiently initializes multiple MCP servers in parallel, reducing setup time and complexity.
-
LangChain Compatibility: Converts MCP server tools into LangChain-compatible tools, allowing easy incorporation into existing LangChain applications.
-
Flexible Configuration: Supports a variety of MCP server configurations, offering flexibility to tailor the setup according to project needs.
-
Asynchronous Operation: Leverages asynchronous operations for efficient resource management, ensuring smooth integration without blocking processes.
-
Cleanup Functionality: Includes a cleanup function to properly close server sessions, maintaining resource integrity and preventing leaks.
With these features, langchain-mcp-tools-ts significantly enhances the usability and functionality of LangChain by providing a robust bridge to the expansive ecosystem of MCP servers. Whether you're building a new AI application or enhancing an existing one, this utility offers a comprehensive solution to expand the capabilities of language models through external tool integration.
How to Use
To use the langchain-mcp-tools-ts, follow these steps:
- Visit https://github.com/hideya/langchain-mcp-tools-tshttps://github.com/hideya...
- Follow the setup instructions to create an account (if required)
- Connect the MCP server to your Claude Desktop application
- Start using langchain-mcp-tools-ts capabilities within your Claude conversations
Additional Information
Created
January 6, 2025
Company
Start building your own MCP Server
Interested in creating your own MCP Server? Check out the official documentation and resources.
Learn More