langchain-mcp
by: rectalogic
Model Context Protocol tool support for LangChain
📌Overview
Purpose: Provide support for calling Model Context Protocol tools within the LangChain framework.
Overview: The langchain-mcp
library enables seamless integration of Model Context Protocol (MCP) tools into LangChain. By creating an MCPToolkit
and initializing a client session, users can access and utilize an array of base tools designed for efficient task execution.
Key Features:
-
MCPToolkit Initialization: Allows users to create a toolkit that manages MCP tools, facilitating easy setup and usage within the LangChain environment.
-
Tool Retrieval: Provides a method to obtain a list of
langchain_core.tools.BaseTool
s, enabling users to efficiently leverage various tools for their applications.
langchain-mcp
Note: langchain now has a more official implementation langchain-mcp-adapters.
Model Context Protocol tool calling support in LangChain.
Create a langchain_mcp.MCPToolkit
with an mcp.ClientSession
, then await toolkit.initialize()
and toolkit.get_tools()
to get the list of langchain_core.tools.BaseTool
s.
Demo
You can run the demo against Groq llama-3.1-8b-instant
:
$ export GROQ_API_KEY=xxx
$ uv run tests/demo.py "Read and summarize the file ./LICENSE"
Secure MCP Filesystem Server running on stdio
Allowed directories: [ '/users/aw/projects/rectalogic/langchain-mcp' ]
The file ./LICENSE is a MIT License agreement. It states that the software is provided "as is" without warranty and that the authors and copyright holders are not liable for any claims, damages, or other liability arising from the software or its use.