https://github.com/datalayer/langchain-mcp-client
🦜🔗 LangChain Model Context Protocol (MCP) Client
https://github.com/datalayer/langchain-mcp-client
langchain mcp-client
Last synced: 9 months ago
JSON representation
🦜🔗 LangChain Model Context Protocol (MCP) Client
- Host: GitHub
- URL: https://github.com/datalayer/langchain-mcp-client
- Owner: datalayer
- License: other
- Created: 2025-02-12T06:44:53.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-02-14T10:41:08.000Z (9 months ago)
- Last Synced: 2025-02-14T10:56:10.765Z (9 months ago)
- Topics: langchain, mcp-client
- Language: Python
- Homepage: https://datalayer.tech
- Size: 68.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-mcp-servers - **langchain-mcp-client** - 🦜🔗 LangChain Model Context Protocol (MCP) Client `jupyter notebook` `langchain` `mcp` `mcp-client` `mcp-server` `git clone https://github.com/datalayer/langchain-mcp-client` (🤖 AI/ML)
- awesome-mcp-servers - **langchain-mcp-client** - 🦜🔗 LangChain Model Context Protocol (MCP) Client `jupyter notebook` `langchain` `mcp` `mcp-client` `mcp-server` `git clone https://github.com/datalayer/langchain-mcp-client` (AI/ML)
README
[](https://datalayer.io)
[](https://github.com/sponsors/datalayer)
# 🦜 🔗 LangChain MCP Client
[](https://github.com/datalayer/langchain-mcp-client/actions/workflows/build.yml)
[](https://pypi.org/project/langchain-mcp-client)
This simple [Model Context Protocol (MCP)](https://modelcontextprotocol.io/)
client demonstrates the use of MCP server tools by LangChain ReAct Agent.
- 🌐 Seamlessly connect to any MCP servers.
- 🤖 Use any LangChain-compatible LLM for flexible model selection.
- 💬 Interact via CLI, enabling dynamic conversations.
## Conversion to LangChain Tools
It leverages a utility function `convert_mcp_to_langchain_tools()` from
[`langchain_mcp_tools`](https://pypi.org/project/langchain-mcp-tools/).
This function handles parallel initialization of specified multiple MCP servers
and converts their available tools into a list of LangChain-compatible tools
([List[BaseTool]](https://python.langchain.com/api_reference/core/tools/langchain_core.tools.base.BaseTool.html#langchain_core.tools.base.BaseTool)).
## Installation
The python version should be 3.11 or higher.
```bash
pip install langchain_mcp_client
```
## Configuration
Create a `.env` file containing all the necessary `API_KEYS` to access your LLM.
Configure the LLM, MCP servers, and prompt example in the `llm_mcp_config.json5` file:
1. **LLM Configuration**: Set up your LLM parameters.
2. **MCP Servers**: Specify the MCP servers to connect to.
3. **Example Queries**: Define example queries that invoke MCP server tools. Press Enter to use these example queries when prompted.
## Usage
```bash
langchain-mcp-client
```
Below an example with [jupyter-mcp-server](https://github.com/datalayer/jupyter-mcp-server):

## Credits
This initial code of this repo is taken from from [hideya/mcp-client-langchain-py](https://github.com/hideya/mcp-client-langchain-py) (MIT License).