LangChain.js MCP Adapters
by vrknetha
This library provides a lightweight wrapper to make Anthropic Model Context Protocol (MCP) tools compatible with LangChain.js and LangGraph.js. It allows you to connect to MCP servers via stdio or SSE and easily integrate MCP tools into your LangChain agents.
Last updated: N/A
What is LangChain.js MCP Adapters?
LangChain.js MCP Adapters is a library that simplifies the integration of tools compliant with the Anthropic Model Context Protocol (MCP) into applications built using LangChain.js and LangGraph.js. It acts as a bridge, allowing you to leverage MCP-based tools within your LangChain workflows.
How to use LangChain.js MCP Adapters?
To use the library, install it via npm. Create an MCP server in python and after which create a MultiServerMCPClient. You can then connect to MCP servers using either stdio or SSE transports. Configure the client using code or JSON files and then use the loadMcpTools
function to automatically have MCP tools available for agent usage. Finally, you can create and utilize LangChain agents with loaded tools.
Key features of LangChain.js MCP Adapters
Transport Options (stdio/SSE)
Multi-Server Management
Agent Integration (LangChain.js, LangGraph.js)
Flexible Configuration Options
Use cases of LangChain.js MCP Adapters
Integrating external tools into LangChain agents using the Model Context Protocol
Connecting to multiple MCP servers simultaneously
Building LangChain agents that can interact with a variety of MCP compliant applications
Orchestrating complex workflows that involve interactions with multiple models and tools to achieve advanced goals.
FAQ from LangChain.js MCP Adapters
What versions of Node.js are supported?
What versions of Node.js are supported?
Node.js version 18 or greater is required.
What Python version is required for stdio transport?
What Python version is required for stdio transport?
Python 3.8 or higher is required for python implementation of MCP.
How do I handle authentication with SSE connections?
How do I handle authentication with SSE connections?
The library supports custom headers for SSE connections. You can provide authentication headers when connecting to the server and Optionally utilize the extended-eventsource
for node.js
Can I use this library in a browser environment?
Can I use this library in a browser environment?
Yes, but with limitations. Native EventSource API doesn't support custom headers, so consider using a proxy or passing authentication via query parameters. Server may also require CORS configuration.
How do I debug connection and execution issues?
How do I debug connection and execution issues?
Verify the MCP server is running and check command paths and network connectivity. Examine server logs for any error messages. Install extended-eventsource
for troubleshooting header issues. Utilized the debug logging package by setting the DEBUG environment variable