russellluo_cmcp

russellluo_cmcp

by russellluo
A command-line utility for interacting with MCP servers, simplifying tasks like listing prompts, reading resources, and calling tools.

Command-Line MCP Client: Streamlining MCP Server Interactions

Overview

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.

Installation

To get started with cmcp, install it via pip:

pip install cmcp

Quick Start

Setting Up an MCP Server

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

Using cmcp with STDIO Transport

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

Using cmcp with SSE Transport

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

About

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.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

0 forks

Releases

v0.1.0 Latest - Mar 23, 2025

Languages

Features & Capabilities

Categories
mcp_server model_context_protocol python command_line api_integration

Implementation Details

Stats

0 Views
2 GitHub Stars

Repository Info

russellluo Organization

Similar MCP Servers

continuedev_continue by continuedev
25049
21423
9300