CLI reference¶
-v turns on debug logging (to stderr) and must come before the command. Commands that
take -c/--config look for ./mcp.json, ./.mcp.json or ./.vscode/mcp.json if it's
not given.
| Command | Purpose |
|---|---|
setup |
Download Pyodide and check the sandbox |
init |
Create mcp.json, optionally importing from (and installing into) an MCP client |
serve |
Run as an MCP server that proxies your servers |
stats |
Tool-definition token cost: classic vs Code Mode |
usage |
Recorded usage and savings |
dashboard |
Local web dashboard |
benchmark |
Head-to-head measured comparison with a real LLM |
chat |
Chat with an LLM that uses your tools through Code Mode |
run |
Run a script against your tools |
search |
Search tools; prints the same stubs the LLM sees |
tools |
Print the tool definitions given to the LLM |
login |
OAuth sign-in to a remote server |
setup¶
Downloads Pyodide into Deno's cache (one time, about 10 MB) and runs a test script.
init¶
| Option | Description |
|---|---|
--from SOURCE |
claude, cursor, vscode, windsurf, or a path to a JSON config |
-o, --output |
Where to write the Code Mode config (default mcp.json; merged if it exists) |
--install |
Replace the client's server list with a single codemode entry. The original is backed up as *.bak-YYYYMMDD-HHMMSS |
serve¶
codemode-mcp serve [-c CONFIG] [--transport {stdio,http}] [--host HOST] [--port PORT] [--dashboard-port PORT]
[--token-env NAME]
| Option | Default | Description |
|---|---|---|
--transport |
stdio |
http serves Streamable HTTP at /mcp, with the dashboard at /dashboard/ |
--host / --port |
127.0.0.1 / 8000 |
Bind address for HTTP (and for the dashboard) |
--dashboard-port |
off | Also serve the dashboard on this port (useful with stdio) |
--token-env |
CODEMODE_TOKEN |
Environment variable holding the access token for HTTP. A token is required when --host is not 127.0.0.1 or localhost; when set, every request must send it as Authorization: Bearer <token> |
stats¶
Connects to the servers and prints the tool-definition cost per request for classic MCP
and for Code Mode, the presentation strategy (inline / search) and the tokenizer.
usage¶
Summary of recorded activity: calls, Code Mode tokens, classic estimate, savings, a
breakdown by call type, top tools, measured LLM usage and benchmarks. --clear deletes
all records.
dashboard¶
Serves the web dashboard and opens it in your browser. Like serve, it needs an access
token (CODEMODE_TOKEN) for any --host other than this machine. See Monitoring.
benchmark¶
codemode-mcp benchmark [-c CONFIG] -m MODEL [--provider {openai,anthropic}] [--base-url URL]
[--api-key-env VAR] [--max-turns 25] [--json] PROMPT
Runs PROMPT with classic tool calling and then with Code Mode, using the same model,
and prints the measured tokens, turns, tool calls, time and both answers. The result is
saved for the dashboard.
chat¶
codemode-mcp chat [-c CONFIG] -m MODEL [--provider {openai,anthropic}] [--base-url URL]
[--api-key-env VAR] [PROMPT]
Without PROMPT it starts an interactive session. With -v (before chat) it prints
every script and result. Tools listed in require_approval ask for confirmation in the
terminal. After each answer it shows the tokens used and saved.
| Provider | Example |
|---|---|
| OpenAI | -m gpt-4.1-mini (reads OPENAI_API_KEY) |
| Anthropic | --provider anthropic -m claude-sonnet-4-5 (reads ANTHROPIC_API_KEY) |
| Ollama | -m llama3.1 --base-url http://localhost:11434/v1 |
| OpenRouter | -m openai/gpt-4.1 --base-url https://openrouter.ai/api/v1 --api-key-env OPENROUTER_API_KEY |
| GitHub Models | -m openai/gpt-4.1-mini --base-url https://models.github.ai/inference --api-key-env GITHUB_TOKEN |
run¶
Runs a script exactly as run_code would, and prints the output. A summary of the tool
calls and token accounting goes to stderr.
search¶
tools¶
login¶
Runs the OAuth sign-in for SERVER (which needs "oauth" in its config) and stores the
tokens. --logout deletes them.