tigerless-labs/cost-xray

See what Claude Code and Codex actually send to the API — and what each part costs.

What it solves

Most AI coding agent usage tools only read local logs, which misses the "invisible" request-time context—such as system prompts, tool schemas, and MCP blocks—that are assembled before the model is invoked. cost-xray provides visibility into the actual API traffic, allowing users to see exactly what is being sent to the model and how much each specific part of the request costs.

How it works

It operates as a local capture hop using mitmproxy. It intercepts the HTTP/HTTPS traffic between the coding agent (like Claude Code or Codex) and the model API. The proxy redacts sensitive information (like API keys) and saves the raw request/response bytes to the local disk. A separate "materializer" then tokenizes and prices the data offline, so it is not on the hot path of the request, ensuring no added latency to the agent's performance.

Who it’s for

Developers using AI coding agents (specifically Claude Code and Codex) on macOS or Linux who want to granularly track their API spend and optimize their context window occupancy.

Highlights

  • Granular Cost Attribution: Traces costs down to the individual tool call and its output, rather than just session totals.
  • Context Window Analysis: Shows exactly what is occupying the context window (e.g., system prompts, MCP servers) to identify "dead weight" in the prefix.
  • Unused MCP Waste Detection: Flags configured MCP servers and tools that are injected into every request but never actually used.
  • Self-Healing Capture: Uses command wrappers that automatically restart the proxy if it is down or route the agent direct if capture fails, ensuring the agent remains functional.
  • Local and Private: All data is stored locally in ~/.cost-xray/ with no telemetry and sensitive fields redacted before storage.

Related

  • Project
  • Project
  • Project
  • Project
  • Project