Published · npm latest v0.9.7

Gemini CLI · experimental, fixture-verified, financial-only

aibill documentation

Let your AI client ask the receipt.

The aibill MCP server exposes the same evidence contract as structured, explicit tools. It is local stdio—not an always-on prompt, proxy, or cloud service.

Updated August 27, 2026

01 · Install

Choose your MCP client

Codex

Terminal
codex mcp add aibill -- npx --yes --package @agent-finops/mcp@latest ai-spend-mcp
codex mcp list

Claude Code

Terminal
claude mcp add --scope user aibill -- npx --yes --package @agent-finops/mcp@latest ai-spend-mcp
claude mcp list

Cursor or another stdio client

mcp.json
{
  "mcpServers": {
    "aibill": {
      "command": "npx",
      "args": ["--yes", "--package", "@agent-finops/mcp@latest", "ai-spend-mcp"]
    }
  }
}

Use ~/.cursor/mcp.json for all Cursor projects or .cursor/mcp.json for one project. Other clients use the same command and arguments at their documented local stdio configuration path.

02 · Tools

Ten bounded operations

scan_ai_spend

Discover provider and configuration signals inside one caller-supplied absolute path and persist local discovery state.

sync_local_agent_spend

Read supported local coding-agent financial metadata and persist a local report.

sync_provider_spend

Read provider billing or usage through an env-reference credential.

get_usage_glance

Return the read-only Claude Code/Codex Glance contract.

get_context_health

Return canonical hook-aware Context Health.

get_token_reduction_test

Read-only: revalidate the bounded local token-reduction experiment and return its matched-session, quality-gated result from the canonical core evaluator.

draft_improve_command

Read-only: validate drafted plan sentences and compose the one paste-safe improve --draft command. It writes nothing and authorizes nothing.

list_sources

Show approved sources and separate status axes.

get_spend_report

Return the current local, provider, or explicitly labeled sample report.

recommend_cuts

Legacy compatibility name for evidence-constrained candidate inspection.

Each scan/sync tool may write local aibill state; sync_provider_spend also contacts the selected provider API. The get, list, draft, and recommendation tools are read-only, and no MCP tool can approve, start, apply, or record anything — approval exists only as the word APPROVE typed by the human in their own terminal. recommend_cuts can return an evidence gap or observed exposure instead of a cut; the name remains for compatibility.

03 · Recommended flow

Sync, ask, inspect the basis

Suggested agent request
Use aibill to sync my local coding-agent evidence for this project.
Then show the spend report, source status, Context Health, and one
evidence-constrained next action. Keep billed cost, API-equivalent value,
subscription context, and missing evidence separate.
  1. Call sync_local_agent_spend with a specific absolute project path.
  2. Read get_spend_report and list_sources.
  3. Ask for get_context_health or get_usage_glance only when that decision surface helps.
  4. Let the client draft a token test with draft_improve_command, then run the composed npx aibill improve --draft … yourself — approval and the quality-gated result stay in your terminal.

With no synced state, get_spend_report returns no_state, zero rows, a null financial headline, and exact next steps. Sample rows appear only after an explicit scan_ai_spend(sample=true) request.

04 · Safety

The client and provider are different boundaries

  • State tools require a specific absolute project path; home, filesystem, and system roots are refused.
  • Raw provider keys are rejected. Provider tools accept an inherited env:NAME reference.
  • Provider syncs are read-only against the selected provider API.
  • This MCP server sends no telemetry and does not upload transcript contents.
  • The selected structured tool result is returned to the invoking AI client and then follows that client’s data policy.
  • A project cannot declare its own connected totals trusted; a separate hash-only local receipt binds trusted provider state to this machine.

05 · Troubleshooting

Fast checks

Tools do not appear
Run the exact npx server command in a terminal, confirm Node 22+, restart the client, and verify that it supports local stdio MCP.
Provider returns 401 or 403
Use an organization/admin billing-read credential rather than a normal inference API key.
A path is refused
Select one project directory. Broad-root refusal is intentional prompt-injection protection.
Report says no_state
Run a local or provider sync for real evidence. No zero-dollar total or sample rows were inferred; sample data requires an explicit demo request.