Quickly test and explore MCP servers from the command line!
A simple, text-based CLI client for Model Context Protocol (MCP) servers built with LangChain and TypeScript.
This tool automatically adjusts the schema for LLM compatibility, which can help some failing MCP servers run successfully.
Suitable for testing MCP servers, exploring their capabilities, and prototyping integrations.
Internally it uses LangChain ReAct Agent and
a utility function convertMcpToLangchainTools()
from
@h1deya/langchain-mcp-tools
.
This function performs the aforementioned MCP tools schema transformations for LLM compatibility.
See this page
for details.
A Python equivalent of this utility is available here
- Node.js 18+
- [optional]
uv
(uvx
) installed to run Python-based local (stdio) MCP servers - LLM API keys from OpenAI, Anthropic, and/or Google AI Studio (for GenAI/Gemini) as needed
-
Install
mcp-client-cli
tool. This can take up to a few minutes to complete:npm install -g @h1deya/mcp-client-cli
-
Configure LLM and MCP Servers settings via the configuration file,
llm_mcp_config.json5
code llm_mcp_config.json5
The following is a simple configuration for quick testing:
{ "llm": { "model_provider": "openai", "model": "gpt-4o-mini", // "model_provider": "anthropic", // "model": "claude-3-5-haiku-latest", // "model_provider": "google_genai", // "model": "gemini-2.5-flash", }, "mcp_servers": { "us-weather": { // US weather only "command": "npx", "args": ["-y", "@h1deya/mcp-server-weather"] }, }, "example_queries": [ "Tell me how LLMs work in a few sentences", "Are there any weather alerts in California?", ], }
-
Set up API keys
echo "ANTHROPIC_API_KEY=sk-ant-... OPENAI_API_KEY=sk-proj-... GOOGLE_API_KEY=AI..." > .env code .env
-
Run the tool
mcp-client-cli
By default, it reads the configuration file,
llm_mcp_config.json5
, from the current directory.
Then, it applies the environment variables specified in the.env
file, as well as the ones that are already defined.
See README_DEV.md for details.
- Easy setup: Works out of the box with popular MCP servers
- Flexible configuration: JSON5 config with environment variable support
- Multiple LLM providers: OpenAI, Anthropic, Google (GenAI)
- Schema Compatibility Support: Automatically adjusts tools schema for LLM compatibility, which can help some failing MCP servers run successfully. See this page for details.
- Command & URL servers: Support for both local and remote MCP servers
- Real-time logging: Live stdio MCP server logs with customizable log directory
- Interactive testing: Example queries for the convenience of repeated testing
- Tool Return Types: Currently, only text results of tool calls are supported.
It uses LangChain's
response_format: 'content'
(the default) internally, which only supports text strings. While MCP tools can return multiple content types (text, images, etc.), this library currently filters and uses only text content. - MCP Features: Only MCP Tools are supported. Other MCP features like Resources, Prompts, and Sampling are not implemented.
mcp-client-cli
By default, it reads the configuration file, llm_mcp_config.json5
, from the current directory.
Then, it applies the environment variables specified in the .env
file,
as well as the ones that are already defined.
It outputs local MCP server logs to the current directory.
# Specify the config file to use
mcp-client-cli --config my-config.json5
# Store local (stdio) MCP server logs in specific directory
mcp-client-cli --log-dir ./logs
# Enable verbose logging
mcp-client-cli --verbose
# Show help
mcp-client-cli --help
- OpenAI:
o4-mini
,gpt-4o-mini
, etc. - Anthropic:
claude-sonnet-4-0
,claude-3-5-haiku-latest
, etc. - Google (GenAI):
gemini-2.5-pro
,gemini-2.5-flash
, etc.
Create a llm_mcp_config.json5
file:
- 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 tomcp_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
{
"llm": {
"model_provider": "openai",
"model": "gpt-4.1-nano",
// model: "o4-mini",
},
// "llm": {
// "model_provider": "anthropic",
// "model": "claude-3-5-haiku-latest",
// // "model": "claude-sonnet-4-0",
// },
// "llm": {
// "model_provider": "google_genai",
// "model": "gemini-2.5-flash",
// // "model": "gemini-2.5-pro",
// }
"example_queries": [
"Tell me how LLMs work in a few sentences",
"Are there any weather alerts in California?",
"Read the news headlines on bbc.com",
],
"mcp_servers": {
// Local MCP server that uses `npx`
"weather": {
"command": "npx",
"args": [ "-y", "@h1deya/mcp-server-weather" ]
},
// Another local server that uses `uvx`
"fetch": {
"command": "uvx",
"args": [ "mcp-server-fetch" ]
},
"brave-search": {
"command": "npx",
"args": [ "-y", "@modelcontextprotocol/server-brave-search" ],
"env": { "BRAVE_API_KEY": "${BRAVE_API_KEY}" }
},
// Remote MCP server via URL
// Auto-detection: tries Streamable HTTP first, falls back to SSE
"remote-mcp-server": {
"url": "https://api.example.com/..."
},
// Server with authentication
"github": {
"type": "http", // recommended to specify the protocol explicitly when authentication is used
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer ${GITHUB_PERSONAL_ACCESS_TOKEN}"
}
}
}
}
Create a .env
file for API keys:
OPENAI_API_KEY=sk-ant-...
ANTHROPIC_API_KEY=sk-proj-...
GOOGLE_API_KEY=AI...
# Other services as needed
GITHUB_PERSONAL_ACCESS_TOKEN=github_pat_...
BRAVE_API_KEY=BSA...
There are quite a few useful MCP servers already available:
- Make sure your configuration and .env files are correct, especially the spelling of the API keys
- Check the local MCP server logs
- Use
--verbose
flag to view the detailed logs - Refer to Debugging Section in MCP documentation
MIT License - see LICENSE file for details.
Issues and pull requests welcome! This tool aims to make MCP server testing as simple as possible.