cmcp
is a command-line utility designed to simplify interactions with MCP (Model Context Protocol) servers. Think of it as curl
for MCP servers, enabling users to manage prompts, resources, and tools efficiently. This tool is particularly useful for developers working with MCP servers, offering a seamless way to execute commands and retrieve data.
To get started with cmcp
, install it via pip:
pip install cmcp
Here’s an example of a basic MCP server setup:
# 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 an addition tool
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b
cmcp
with STDIO TransportInteract with the MCP server using the STDIO transport:
List Prompts:
shell
cmcp 'mcp run server.py' prompts/list
Get a Prompt:
shell
cmcp 'mcp run server.py' prompts/get -d '{"name": "review_code", "arguments": {"code": "def greet(): pass"}}'
List Resources:
shell
cmcp 'mcp run server.py' resources/list
Read a Resource:
shell
cmcp 'mcp run server.py' resources/read -d '{"uri": "config://app"}'
List Tools:
shell
cmcp 'mcp run server.py' tools/list
Call a Tool:
shell
cmcp 'mcp run server.py' tools/call -d '{"name": "add", "arguments": {"a": 1, "b": 2}}'
cmcp
with SSE TransportRun the MCP server with SSE (Server-Sent Events) transport:
mcp run server.py -t sse
List Prompts:
shell
cmcp http://localhost:8000 prompts/list
Get a Prompt:
shell
cmcp http://localhost:8000 prompts/get -d '{"name": "review_code", "arguments": {"code": "def greet(): pass"}}'
List Resources:
shell
cmcp http://localhost:8000 resources/list
Read a Resource:
shell
cmcp http://localhost:8000 resources/read -d '{"uri": "config://app"}'
List Tools:
shell
cmcp http://localhost:8000 tools/list
Call a Tool:
shell
cmcp http://localhost:8000 tools/call -d '{"name": "add", "arguments": {"a": 1, "b": 2}}'
cmcp
is a powerful command-line utility for interacting with MCP servers, making it easier to manage and utilize MCP resources. Whether you're working with prompts, resources, or tools, cmcp
provides a straightforward and efficient way to interact with your MCP server.