cmcp

MCP.Pizza Chef: RussellLuo

cmcp is a command-line client designed to interact with MCP servers using JSON-RPC over STDIO or SSE. It functions like a curl tool for MCP, enabling developers to send commands, methods, parameters, environment variables, and headers easily. cmcp supports verbose mode for debugging and simplifies communication with MCP servers in development and automation workflows.

Use This MCP client To

Send JSON-RPC commands to MCP servers from the terminal Test and debug MCP server endpoints interactively Automate MCP server interactions in shell scripts Pass complex JSON parameters and environment variables to MCP servers Use verbose mode to inspect JSON-RPC requests and responses Interact with MCP servers over STDIO or SSE protocols

README

cMCP

cmcp is a command-line utility that helps you interact with MCP servers. It's basically curl for MCP servers.

Installation

pip install cmcp

Usage

STDIO

Interact with the STDIO server:

cmcp COMMAND METHOD

Add required parameters:

cmcp COMMAND METHOD param1=value param2:='{"arg1": "value"}'

Add required environment variables:

cmcp COMMAND METHOD ENV_VAR1:value ENV_VAR2:value param1=value param2:='{"arg1": "value"}'

SSE

Interact with the SSE server:

cmcp URL METHOD

Add required parameters:

cmcp URL METHOD param1=value param2:='{"arg1": "value"}'

Add required HTTP headers:

cmcp URL METHOD Header1:value Header2:value param1=value param2:='{"arg1": "value"}'

Verbose mode

Enable verbose mode to show JSON-RPC request and response:

cmcp -v COMMAND_or_URL METHOD

Quick Start

Given the following MCP Server (see here):

# server.py
from mcp.server.fastmcp import FastMCP

# Create an MCP server
mcp = FastMCP("Demo")


# Add a prompt
@mcp.prompt()
def review_code(code: str) -> str:
    return f"Please review this code:\n\n{code}"


# Add a static config resource
@mcp.resource("config://app")
def get_config() -> str:
    """Static configuration data"""
    return "App configuration here"


# Add a dynamic greeting resource
@mcp.resource("greeting://{name}")
def get_greeting(name: str) -> str:
    """Get a personalized greeting"""
    return f"Hello, {name}!"


# Add an addition tool
@mcp.tool()
def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b

STDIO transport

List prompts:

cmcp 'mcp run server.py' prompts/list

Get a prompt:

cmcp 'mcp run server.py' prompts/get name=review_code arguments:='{"code": "def greet(): pass"}'

List resources:

cmcp 'mcp run server.py' resources/list

Read a resource:

cmcp 'mcp run server.py' resources/read uri=config://app

List resource templates:

cmcp 'mcp run server.py' resources/templates/list

List tools:

cmcp 'mcp run server.py' tools/list

Call a tool:

cmcp 'mcp run server.py' tools/call name=add arguments:='{"a": 1, "b": 2}'

SSE transport

Run the above MCP server with SSE transport:

mcp run server.py -t sse

List prompts:

cmcp http://localhost:8000 prompts/list

Get a prompt:

cmcp http://localhost:8000 prompts/get name=review_code arguments:='{"code": "def greet(): pass"}'

List resources:

cmcp http://localhost:8000 resources/list

Read a resource:

cmcp http://localhost:8000 resources/read uri=config://app

List resource templates:

cmcp http://localhost:8000 resources/templates/list

List tools:

cmcp http://localhost:8000 tools/list

Call a tool:

cmcp http://localhost:8000 tools/call name=add arguments:='{"a": 1, "b": 2}'

cmcp FAQ

How do I install cmcp?
Install cmcp easily using pip with the command `pip install cmcp`.
Can cmcp interact with different MCP server protocols?
Yes, cmcp supports both STDIO and SSE protocols for communicating with MCP servers.
How do I pass JSON parameters to cmcp commands?
Use the syntax `param2:='{"arg1": "value"}'` to pass JSON objects as parameters.
What is verbose mode in cmcp?
Verbose mode shows the full JSON-RPC request and response for debugging purposes.
Can I add HTTP headers or environment variables with cmcp?
Yes, you can add HTTP headers for SSE or environment variables for STDIO interactions.
Is cmcp suitable for automation?
Absolutely, cmcp can be used in scripts to automate interactions with MCP servers.
Does cmcp support multiple MCP servers?
Yes, you specify the MCP server URL or command to target different servers.
What platforms does cmcp support?
cmcp is a Python package and works on any platform supporting Python and pip.