Simple CLI MCP Client Using LangChain / Python
- agent-framework
Simple CLI MCP Client Implementation Using LangChain ReAct Agent / Python
About
What is Simple CLI MCP Client Using LangChain / Python?
A command‑line application that demonstrates how to use Model Context Protocol (MCP) server tools via the LangChain ReAct Agent. It runs on Python 3.11+ and is aimed at developers integrating MCP with LangChain.
How to use Simple CLI MCP Client Using LangChain / Python?
Install dependencies with make install, copy .env.template to .env and populate API keys for Anthropic, OpenAI, and/or Groq. Configure LLM and MCP servers in llm_mcp_config.json5 (JSON5 format with environment variable substitution). Run with make start; press Enter at the prompt to use built‑in example queries that invoke MCP tools.
Key features of Simple CLI MCP Client Using LangChain / Python
- Converts MCP tools into LangChain‑compatible BaseTool objects via convert_mcp_to_langchain_tools()
- Supports parallel initialization of multiple MCP servers
- Works with LLMs from Anthropic, OpenAI, and Groq
- Config file uses JSON5 (comments, trailing commas) and ${...} env variable substitution
- Includes configurable example queries for quick testing
Use cases of Simple CLI MCP Client Using LangChain / Python
- Prototype a LangChain ReAct agent that calls MCP‑exposed tools
- Test MCP server integration without a full IDE or desktop app
- Compare tool‑calling behavior across different LLM providers
- Automate CLI workflows that chain multiple MCP tool invocations
FAQ from Simple CLI MCP Client Using LangChain / Python
What is the Model Context Protocol (MCP)?
MCP is an open protocol that standardises how applications provide context and tools to LLMs. This client connects to MCP servers and exposes their tools to a LangChain agent.
Which LLM providers are supported?
Anthropic, OpenAI, and Groq are currently supported. You must provide the corresponding API keys in .env.
How does the config file differ from Claude for Desktop’s?
The configuration follows the same structure as Claude for Desktop’s mcpServers, but the key name is changed to mcp_servers (snake_case) to match JSON conventions.
How do I set up API keys?
Copy .env.template to .env, then fill in the keys. The .gitignore already excludes .env to prevent accidental commits. Use ${KEY_NAME} in the JSON5 config to reference environment variables.
Is there a TypeScript version?
Yes, a TypeScript version of this MCP client is available here.
What is the license?
The project is released under the MIT License.
Details
- Author
- hideya
- GitHub stars
- 9
- Category
- agent-framework
- Repository
- hideya/mcp-client-langchain-py
Simple CLI MCP Client Using LangChain / Python 
This simple Model Context Protocol (MCP)
client with command line interface demonstrates the use of MCP server tools by the LangChain ReAct Agent.
It leverages a utility function convert_mcp_to_langchain_tools() from
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)).
LLMs from Anthropic, OpenAI and Groq are currently supported.
A typescript version of this MCP client is available
here
Prerequisites
- Python 3.11+
- [optional] uv (uvx)
installed to run Python package-based MCP servers
- [optional] npm 7+ (npx)
to run Node.js package-based MCP servers
- API keys from Anthropic,
OpenAI, and/or
Groq
as needed
Setup
1. Install dependencies:
make install
2. Setup API keys:
cp .env.template .env
- Update
.env as needed.-
.gitignore is configured to ignore .envto prevent accidental commits of the credentials.
3. Configure LLM and MCP Servers settings llm_mcp_config.json5 as needed.
- The configuration file format
for MCP servers follows the same structure as
Claude for Desktop,
with one difference: the key name mcpServers has been changed
to mcp_servers to follow the snake_case convention
commonly used in JSON configuration files.
- The file format is JSON5,
where comments and trailing commas are allowed.
- The format is further extended to replace ${...} notations
with the values of corresponding environment variables.
- Keep all the credentials and private info in the .env file
and refer to them with ${...} notation as needed.
Usage
Run the app:
make start
It takes a while on the first run.
Run in verbose mode:
make start-v
See commandline options:
make start-h
At the prompt, you can simply press Enter to use example queries that perform MCP server tool invocations.
Example queries can be configured in llm_mcp_config.json5
