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.
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:
| Command | Description |
uv run mcp run server.py | Run server directly via stdio |
uv run mcp run server.py:myapp | Run a specific server object from file |
uv run mcp run server.py --transport streamable-http | Run with HTTP transport |
uv run mcp dev server.py | Open server in MCP Inspector (GUI) |
uv run mcp dev server.py --with pandas | Dev mode with extra dependencies |
uv run mcp install server.py | Register 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 .env | Register with env vars |
Tool & Resource Operations
Interact with running MCP servers using mcptools:
| Command | Description |
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 |
or http://host:port or a pre-configured alias.Transport Configuration
Transport CLI Flag Use Case
stdio default Local servers, launched as subprocess
streamable-http --transport streamable-http Deployed/production servers
sse legacy Old 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 MCPServermcp = 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 Clientasync 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)
| Command | Level | ||
|---|---|---|---|
pip install mcp[cli]Install MCP Python SDK with CLI tools | Basic | pip install mcp[cli] | |
uv run mcp dev server.pyLaunch server under MCP Inspector for development | Intermediate | uv run mcp dev server.py | |
uv run mcp dev server.py --with pandas --with numpyStart Inspector with extra Python packages | Intermediate | uv run mcp dev server.py --with pandas --with numpy | |
uv run mcp dev server.py --with-editable .Start dev mode with editable local package | Intermediate | uv run mcp dev server.py --with-editable . | |
uv run mcp install server.pyRegister server with Claude Desktop app | Basic | uv run mcp install server.py | |
uv run mcp install server.py --name "Bookshop"Register with custom display name | Intermediate | uv run mcp install server.py --name "Bookshop" | |
uv run mcp install server.py -v API_KEY=abc123 -f .envInstall server with environment variables | Intermediate | uv run mcp install server.py -v API_KEY=abc123 -f .env |
Basic Operations(3)
| Command | Level | ||
|---|---|---|---|
uv run mcp run server.pyRun MCP server directly | Basic | uv run mcp run server.py | |
uv run mcp run server.py:bookshopRun MCP server from a specific Python object | Intermediate | uv run mcp run server.py:bookshop | |
uv run mcp versionShow installed MCP SDK version | Basic | uv run mcp version |
Transport Config(1)
| Command | Level | ||
|---|---|---|---|
uv run mcp run server.py --transport streamable-httpRun server with Streamable HTTP transport | Intermediate | uv run mcp run server.py --transport streamable-http |
Tool & Resource Ops(7)
| Command | Level | ||
|---|---|---|---|
mcp toolsList all available tools from a server | Basic | mcp tools npx -y @modelcontextprotocol/server-filesystem ~ | |
mcp call read_fileCall a tool with JSON parameters | Basic | mcp call read_file --params '{"path":"README.md"}' npx -y @modelcontextprotocol/server-filesystem ~
| |
mcp resourcesList all available resources from a server | Basic | mcp resources http://localhost:3000 | |
mcp promptsList all available prompts from a server | Basic | mcp prompts npx -y @modelcontextprotocol/server-everything | |
mcp read-resourceRead content of a specific resource | Intermediate | mcp read-resource file:///etc/hosts --params '{}' npx -y @modelcontextprotocol/server-filesystem ~
| |
mcp get-promptGet a specific prompt by name | Intermediate | mcp get-prompt simple_prompt npx -y @modelcontextprotocol/server-everything | |
mcp shellStart interactive MCP shell session | Intermediate | mcp shell npx -y @modelcontextprotocol/server-filesystem ~ |
Advanced(3)
| Command | Level | ||
|---|---|---|---|
mcp webStart web UI for MCP server management | Expert | mcp web --port 8080 http://localhost:3000 | |
mcp new tool:calculate resource:fileScaffold new MCP project components | Expert | mcp new tool:calculate resource:file prompt:greet | |
mcp mockCreate a mock MCP server for testing | Expert | mcp mock my-server --tools 5 --resources 3 |
Configuration(5)
| Command | Level | ||
|---|---|---|---|
mcp alias add myfsAdd a short alias for a server command | Intermediate | mcp alias add myfs npx -y @modelcontextprotocol/server-filesystem ~/ | |
mcp alias listList all configured server aliases | Basic | mcp alias list | |
mcp alias remove myfsRemove a specific server alias | Basic | mcp alias remove myfs | |
mcp configs scanScan IDE and Claude configs for MCP servers | Expert | mcp configs scan | |
mcp configs set vscode my-serverSet MCP server in VS Code config | Expert | mcp configs set vscode my-server npm run mcp-server |