LangChain MCP Client logo

LangChain MCP Client

by datalayer

This client demonstrates the use of MCP server tools by LangChain ReAct Agent, enabling seamless connection to MCP servers and flexible model selection. It allows interaction via CLI for dynamic conversations.

View on GitHub

Last updated: N/A

What is LangChain MCP Client?

The LangChain MCP Client is a tool that allows LangChain agents to interact with Model Context Protocol (MCP) servers. It provides a way to convert MCP server tools into LangChain-compatible tools, enabling agents to utilize these tools within their workflows.

How to use LangChain MCP Client?

  1. Install the client using pip install langchain_mcp_client. 2. Configure your LLM and MCP servers in the llm_mcp_config.json5 file, including API keys in a .env file. 3. Launch the CLI using make cli after starting the desired MCP server (e.g., Jupyter MCP Server). 4. Interact with the agent by providing prompts, optionally using example queries defined in the configuration file.

Key features of LangChain MCP Client

  • Seamless connection to any MCP servers.

  • Use of any LangChain-compatible LLM.

  • CLI interaction for dynamic conversations.

  • Conversion of MCP tools to LangChain-compatible tools.

  • Configuration via JSON5 file.

Use cases of LangChain MCP Client

  • Integrating external tools and services into LangChain agents.

  • Enabling agents to access and utilize models hosted on MCP servers.

  • Building conversational AI applications that leverage external knowledge and capabilities.

  • Automating tasks that require interaction with various models and services.

FAQ from LangChain MCP Client

What is MCP?

MCP stands for Model Context Protocol. It's a protocol for standardizing the interaction with models and tools.

What Python version is required?

Python 3.11 or higher is required.

How do I configure the client?

Configuration is done through the llm_mcp_config.json5 file and a .env file for API keys.

What is the convert_mcp_to_langchain_tools() function?

This function converts MCP server tools into a list of LangChain-compatible tools.

Where does the code come from?

The initial code is taken from hideya/mcp-client-langchain-py and from langchain_mcp_tools.