langchain-mcp
by rectalogic
langchain-mcp provides Model Context Protocol tool calling support in LangChain. It allows you to integrate tools that adhere to the Model Context Protocol into your LangChain applications.
Last updated: N/A
What is langchain-mcp?
langchain-mcp is a library that enables LangChain to utilize tools that implement the Model Context Protocol (MCP). It provides a way to create and manage toolkits that can be used within LangChain agents and chains.
How to use langchain-mcp?
To use langchain-mcp, create an MCPToolkit
with an mcp.ClientSession
. Then, initialize the toolkit using await toolkit.initialize()
and retrieve the list of tools using toolkit.get_tools()
. This will return a list of langchain_core.tools.BaseTool
objects that can be used within LangChain.
Key features of langchain-mcp
Model Context Protocol support
Integration with LangChain
Dynamic tool discovery
Secure filesystem access (as demonstrated in the demo)
Easy integration with MCP-compliant tools
Use cases of langchain-mcp
Accessing and manipulating files securely within a LangChain agent
Integrating external services that use the Model Context Protocol
Building AI agents that can interact with the real world through MCP-compliant tools
Creating secure and sandboxed environments for AI agents
Summarizing content of files
FAQ from langchain-mcp
What is Model Context Protocol (MCP)?
What is Model Context Protocol (MCP)?
Model Context Protocol is a protocol for securely providing models with access to external resources and tools.
How does langchain-mcp relate to LangChain?
How does langchain-mcp relate to LangChain?
langchain-mcp provides a way to use MCP-compliant tools within LangChain agents and chains.
What is an MCPToolkit?
What is an MCPToolkit?
An MCPToolkit is a class in langchain-mcp that manages the connection to an MCP server and provides a list of tools to LangChain.
How do I get a list of tools from an MCPToolkit?
How do I get a list of tools from an MCPToolkit?
Call the get_tools()
method on an initialized MCPToolkit to retrieve a list of langchain_core.tools.BaseTool
objects.
Where can I find more information about the Model Context Protocol?
Where can I find more information about the Model Context Protocol?
You can find more information at https://modelcontextprotocol.io