MCP ExplorerExplorer

Cmcp

@RussellLuoon a year ago
9 MIT
FreeCommunity
AI Systems
#mcp#model-context-protocol
A command-line utility for interacting with MCP servers.

Overview

What is Cmcp

cmcp is a command-line utility designed for interacting with MCP servers, functioning similarly to curl but specifically for MCP.

Use cases

Use cases for cmcp include reviewing code snippets, retrieving application configuration data, and performing calculations using defined tools, all through command-line interactions.

How to use

To use cmcp, install it via pip with the command ‘pip install cmcp’. You can then run commands to interact with your MCP server, such as listing prompts, resources, and tools, or calling specific tools with arguments.

Key features

Key features of cmcp include the ability to list and retrieve prompts, resources, and tools from an MCP server, as well as the capability to call tools with specific arguments. It supports both STDIO and SSE transport methods.

Where to use

cmcp can be used in various fields where MCP servers are implemented, such as software development, data processing, and automation tasks.

Content

cMCP

cmcp logo

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

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers