Skip to content

MCP server ​

tokenops serve starts a Model Context Protocol server that exposes TokenOps queries as tools. Register it in any MCP client (Claude Desktop, Cursor, opencode, your own agent) to let an LLM ask "how much did we spend last week?" or "show me the top wasteful workflows" — answered from the local event store.

Tools ​

Sixteen tools, each answering one question. Most pick their slice with a view (or an action or setting where they change something), so an agent chooses between sixteen clear options instead of fifty near neighbours, and reads far fewer tokens of tool definitions before its first call. Every tool has a title, annotations a client can base approval on (readOnlyHint, destructiveHint, idempotentHint), described parameters, and an output schema; a parameter that does not apply to the chosen view is refused with a message saying which ones do.

ToolAnswersViews, actions or settings
tokenops_glanceEvery plan's windows with pace, spend against limits, the session budget, the coach's findingsall, headroom, session_budget, findings
tokenops_spendWhat was spent and wheresummary, top, burn, forecast, commits, units, waste, tags
tokenops_sessionsHow agent sessions godx, story, prompts
tokenops_statusWhether TokenOps is working and how it is set upstatus, mode, config, data_sources, vendor_usage, version
tokenops_explainWhat a figure means, or why a decision was madeterm or decision_id
tokenops_recordsWhat TokenOps recordedoptimizations, audit, events, workflow, scorecard, verify
tokenops_rulesThe repository's agent rules filesanalyze, conflicts, compress, inject
tokenops_fmtCommand-output compressionlearn, analyze
tokenops_pricingModel prices from the rate card—
tokenops_prepare_workHeadroom and a model recommendation before a task—
tokenops_review_workOne workflow reviewed after a task—
tokenops_outcomeHow a piece of work turned outrecord, detect
tokenops_routingWhich model a turn should run on, and routing governanceadvise, proposals, decide, set_rule
tokenops_configureChange a settingplan, budget, mode, preferred_model, usage_meter
tokenops_coachHow much the coach says and does—
tokenops_experimentA bounded routing trialstart, status, stop (as action)

The read tools are marked read-only; tokenops_prepare_work and tokenops_outcome record evidence without changing settings; tokenops_routing, tokenops_configure, tokenops_coach and tokenops_experiment change settings and are marked so a client asks first. The developer tools (eval, replay, coverage-debt, rules bench) are CLI commands only.

Claude Desktop setup ​

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

json
{
  "mcpServers": {
    "tokenops": {
      "command": "tokenops",
      "args": ["serve"],
      "env": {
        "TOKENOPS_STORAGE_PATH": "/Users/<you>/.tokenops/events.db"
      }
    }
  }
}

Restart Claude Desktop. The TokenOps tools surface in the tools list.

Cursor / other clients ​

Any client speaking MCP over stdio works. Run tokenops serve as the command; pass TOKENOPS_STORAGE_PATH to point at the events DB.

Logs ​

Diagnostic output goes to stderr (stdout is reserved for the JSON-RPC channel). Tail it via tokenops serve 2>/tmp/tokenops-serve.log.

Apache 2.0 licensed.