Skip to main content

MCP CLI Cheatsheet

The Model Context Protocol (MCP) is an open standard by Anthropic that connects AI applications to external tools and data sources. The MCP CLI ecosystem spans two main toolchains: the Python SDK CLI (mcp dev/run/install) for building and registering MCP servers, and mcptools (mcp call/tools/resources) for interacting with running servers.

Updated: 2026-07-20·26 commands

Overview

MCP (Model Context Protocol) is an open protocol for connecting AI applications to external tools and data sources. MCP servers expose tools (executable functions), resources (data sources), and prompts (reusable templates). The CLI ecosystem has two main tools:

- Python SDK CLI (pip install mcp[cli]) — for building, running, and installing MCP servers - mcptools (brew install mcp or go install) — for interacting with running MCP servers

Installation & Setup

``bash # Install Python SDK with CLI pip install mcp[cli]

# Or use uv (faster) uv add mcp[cli]

# Install mcptools (Go-based client CLI) brew tap f/mcptools && brew install mcp # or: go install github.com/f/mcptools/cmd/mcptools@latest `

Quick Start

`bash # 1. Create a server file echo 'from mcp.server import MCPServer mcp = MCPServer("Demo")

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

if __name__ == "__main__": mcp.run()' > server.py

# 2. Run with Inspector uv run mcp dev server.py

# 3. Run directly via stdio uv run mcp run server.py

# 4. Install for Claude Desktop uv run mcp install server.py --name "Demo"

# 5. List available tools (mcptools) mcp tools npx -y @modelcontextprotocol/server-filesystem ~

# 6. Call a tool mcp call read_file --params '{"path":"README.md"}' npx -y @modelcontextprotocol/server-filesystem ~ `

Server Management

Run, install, and manage MCP servers:

CommandDescription
uv run mcp run server.pyRun server directly via stdio
uv run mcp run server.py:myappRun a specific server object from file
uv run mcp run server.py --transport streamable-httpRun with HTTP transport
uv run mcp dev server.pyOpen server in MCP Inspector (GUI)
uv run mcp dev server.py --with pandasDev mode with extra dependencies
uv run mcp install server.pyRegister with Claude Desktop
uv run mcp install server.py --name "MyApp"Register with custom name
uv run mcp install server.py -v KEY=val -f .envRegister with env vars

Tool & Resource Operations

Interact with running MCP servers using mcptools:

CommandDescription
mcp tools List all available tools
mcp call --params '{}' Call a tool with JSON params
mcp resources List all available resources
mcp read-resource Read a specific resource
mcp prompts List all available prompts
mcp get-prompt Get a specific prompt template
mcp shell Start interactive shell session
Server argument: either
npx -y @modelcontextprotocol/server-* or http://host:port or a pre-configured alias.

Transport Configuration

TransportCLI FlagUse Case
stdiodefaultLocal servers, launched as subprocess
streamable-http--transport streamable-httpDeployed/production servers
sselegacyOld HTTP transport (deprecated)
Configure HTTP transport options in
mcp.run(): `python mcp.run( transport="streamable-http", host="0.0.0.0", port=3001, json_response=True, max_request_body_size=4_194_304, # 4 MiB ) `

Configuration

Manage aliases and scan for server configs:

`bash # Create an alias for frequent use mcp alias add myfs npx -y @modelcontextprotocol/server-filesystem ~/

# List all aliases mcp alias list

# Remove an alias mcp alias remove myfs

# Scan IDE/Claude configs for MCP servers mcp configs scan

# Set a server config in VS Code mcp configs set vscode my-server npm run mcp-server `

Advanced Usage

### Interactive Shell

`bash mcp shell npx -y @modelcontextprotocol/server-filesystem ~ # > tools # > call read_file --params '{"path":"README.md"}' # > format json # > /q `

### Web UI

`bash mcp web --port 8080 http://localhost:3000 `

### Scaffold a New Project

`bash mcp new tool:calculate resource:file prompt:greet `

Creates a complete TypeScript MCP project with these components pre-wired.

### Mock Server for Testing

`bash mcp mock my-server --tools 5 --resources 3 `

### Code: Python Server Skeleton

`python from mcp.server import MCPServer

mcp = MCPServer("MyApp", log_level="DEBUG")

@mcp.tool() def search_books(query: str) -> str: """Search the catalog by title or author.""" return f"Found results for {query!r}."

@mcp.resource("greeting://{name}") def greeting(name: str) -> str: """Personalized greeting.""" return f"Hello, {name}!"

if __name__ == "__main__": mcp.run() `

### Code: Python Client

`python import asyncio from mcp import Client

async def main(): async with Client(mcp) as client: # or Client("http://host:port") result = await client.call_tool("search_books", {"query": "mcp"}) print(result.structured_content)

asyncio.run(main()) `

FAQ

### How do I update MCP SDK? `bash pip install --upgrade mcp[cli] # or uv add --dev mcp[cli]@latest ` For v2 pre-releases, pin an exact version: pip install mcp[cli]==2.0.0b1.

### Why doesn't mcp run find my server object? mcp run server.py imports the file and looks for a global mcp, server, or app variable of type MCPServer. If your object has a different name, use server.py:myobject syntax. Also ensure mcp.run() is guarded by if __name__ == "__main__": — that block doesn't execute under mcp run.

### How do I debug an MCP server? - Use uv run mcp dev server.py to open the Inspector GUI - Set log_level="DEBUG" in MCPServer("Name", log_level="DEBUG") - Logs go to stderr (stdout is the MCP protocol wire — no print() statements) - Use mcp mock --tools 3 for isolated testing without real servers

### Can I use MCP with VS Code or Cursor? Yes. Most modern AI coding tools support MCP. Use the LLM app's own config (e.g., VS Code settings.json, Cursor's mcp.json) or use mcp configs set to register a server: mcp configs set cursor my-server npx ...`.

Install & Setup(7)

CommandLevel
pip install mcp[cli]
Install MCP Python SDK with CLI tools
Basic
uv run mcp dev server.py
Launch server under MCP Inspector for development
Intermediate
uv run mcp dev server.py --with pandas --with numpy
Start Inspector with extra Python packages
Intermediate
uv run mcp dev server.py --with-editable .
Start dev mode with editable local package
Intermediate
uv run mcp install server.py
Register server with Claude Desktop app
Basic
uv run mcp install server.py --name "Bookshop"
Register with custom display name
Intermediate
uv run mcp install server.py -v API_KEY=abc123 -f .env
Install server with environment variables
Intermediate

Basic Operations(3)

CommandLevel
uv run mcp run server.py
Run MCP server directly
Basic
uv run mcp run server.py:bookshop
Run MCP server from a specific Python object
Intermediate
uv run mcp version
Show installed MCP SDK version
Basic

Transport Config(1)

CommandLevel
uv run mcp run server.py --transport streamable-http
Run server with Streamable HTTP transport
Intermediate

Tool & Resource Ops(7)

CommandLevel
mcp tools
List all available tools from a server
Basic
mcp call read_file
Call a tool with JSON parameters
Basic
mcp resources
List all available resources from a server
Basic
mcp prompts
List all available prompts from a server
Basic
mcp read-resource
Read content of a specific resource
Intermediate
mcp get-prompt
Get a specific prompt by name
Intermediate
mcp shell
Start interactive MCP shell session
Intermediate

Advanced(3)

CommandLevel
mcp web
Start web UI for MCP server management
Expert
mcp new tool:calculate resource:file
Scaffold new MCP project components
Expert
mcp mock
Create a mock MCP server for testing
Expert

Configuration(5)

CommandLevel
mcp alias add myfs
Add a short alias for a server command
Intermediate
mcp alias list
List all configured server aliases
Basic
mcp alias remove myfs
Remove a specific server alias
Basic
mcp configs scan
Scan IDE and Claude configs for MCP servers
Expert
mcp configs set vscode my-server
Set MCP server in VS Code config
Expert

FAQ

This cheatsheet is compiled from official tool documentation. Last updated: 2026-07-20.