Skip to main content

Simple MCP Client to quickly test and explore MCP servers from the command line

Project description

Simple MCP Client to Explore MCP Servers License: MIT pypi version

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 Python.
Suitable for testing MCP servers, exploring their capabilities, and prototyping integrations.

Internally it uses LangChain ReAct Agent and a utility function convert_mcp_to_langchain_tools() from langchain_mcp_tools.

A TypeScript equivalent of this utility is available here

Prerequisites

Quick Start

  • Install mcp-chat tool. This can take up to a few minutes to complete:

    pip install mcp-chat
    
  • 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": {
        "provider": "openai",       "model": "gpt-5-mini",
        // "provider": "anthropic",    "model": "claude-3-5-haiku-latest",
        // "provider": "google_genai", "model": "gemini-2.5-flash",
        // "provider": "xai",          "model": "grok-3-mini",
        // "provider": "cerebras",     "model": "gpt-oss-120b",
        // "provider": "groq",         "model": "openai/gpt-oss-20b",
      },
    
      "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...
    XAI_API_KEY=xai-...
    CEREBRAS_API_KEY=csk-...
    GROQ_API_KEY=gsk_..." > .env
    
    code .env
    
  • Run the tool

    mcp-chat
    

    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.

Building from Source

See README_DEV.md for details.

Features

  • Easy setup: Works out of the box with popular MCP servers
  • Flexible configuration: JSON5 config with environment variable support
  • Multiple LLM/API providers: OpenAI, Anthropic, Google (GenAI), xAI, Ceberas, Groq
  • Command & URL servers: Support for both local and remote MCP servers
  • Local MCP Server logging: Save stdio MCP server logs with customizable log directory
  • Interactive testing: Example queries for the convenience of repeated testing

Limitations

  • 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.

Usage

Basic Usage

mcp-chat

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.

With Options

# Specify the config file to use
mcp-chat --config my-config.json5

# Store local (stdio) MCP server logs in specific directory
mcp-chat --log-dir ./logs

# Enable verbose logging
mcp-chat --verbose

# Show help
mcp-chat --help

Supported Model/API Providers

  • OpenAI: gpt-5-mini, gpt-4.1-nano, etc.
  • Anthropic: claude-sonnet-4-0, claude-3-5-haiku-latest, etc.
  • Google (GenAI): gemini-2.5-flash, gemini-2.5-pro, etc.
  • xAI: grok-3-mini, grok-4, etc.
  • Cerebras: gpt-oss-120b, etc.
  • Groq: openai/gpt-oss-20b, openai/gpt-oss-120b, etc.

Configuration

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 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
{
  "llm": {
    "provider": "openai",
    "model": "gpt-4.1-nano",
    // model: "gpt-5-mini",
  },

  // "llm": {
  //   "provider": "anthropic",
  //   "model": "claude-3-5-haiku-latest",
  //   // "model": "claude-sonnet-4-0",
  // },

  // "llm": {
  //   "provider": "google_genai",
  //   "model": "gemini-2.5-flash",
  //   // "model": "gemini-2.5-pro",
  // },

  // "llm": {
  //   "provider": "xai",
  //   "model": "grok-3-mini",
  //   // "model": "grok-4",
  // },

  // "llm": {
  //   "provider": "cerebras",
  //   "model": "gpt-oss-120b",
  // },

  // "llm": {
  //   "provider": "groq",
  //   "model": "openai/gpt-oss-20b",
  //   // "model": "openai/gpt-oss-120b",
  // },

  "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}"
      }
    }
  }
}

Environment Variables

Create a .env file for API keys:

OPENAI_API_KEY=sk-ant-...
ANTHROPIC_API_KEY=sk-proj-...
GOOGLE_API_KEY=AI...
XAI_API_KEY=xai-...
CEREBRAS_API_KEY=csk-...
GROQ_API_KEY=gsk_...

# Other services as needed
GITHUB_PERSONAL_ACCESS_TOKEN=github_pat_...
BRAVE_API_KEY=BSA...

Popular MCP Servers to Try

There are quite a few useful MCP servers already available:

Troubleshooting

  • 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

Change Log

Can be found here

License

MIT License - see LICENSE file for details.

Contributing

Issues and pull requests welcome! This tool aims to make MCP server testing as simple as possible.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_chat-0.2.14.tar.gz (140.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_chat-0.2.14-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file mcp_chat-0.2.14.tar.gz.

File metadata

  • Download URL: mcp_chat-0.2.14.tar.gz
  • Upload date:
  • Size: 140.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for mcp_chat-0.2.14.tar.gz
Algorithm Hash digest
SHA256 ed50b3e70ef3d54bba14024980b3dfc6a263bb9da9fcaaa6e24a25ad34163095
MD5 3d36281e793317ca980549f343d5e1f8
BLAKE2b-256 be5d98b7197057a5f02b70a75f0cc5a27f51af527a629125bf1c8e939715c5a5

See more details on using hashes here.

File details

Details for the file mcp_chat-0.2.14-py3-none-any.whl.

File metadata

  • Download URL: mcp_chat-0.2.14-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for mcp_chat-0.2.14-py3-none-any.whl
Algorithm Hash digest
SHA256 4a9338985999e263e77069a55b63d0cea69eb0ee82ce6b41dc4e91ef666587c3
MD5 100ebf165e90bfaf854a5b4dad5b8832
BLAKE2b-256 7feb05f07f33bf633e55745379746f7f3d5dce00319412a47796c6217f3310e8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page