Skip to content

Tracing a cost spike to the commit, with your own coding agent

The CostReveal team, , 4 minute read

A cost spike is rarely a mystery about money. It is a question about code: which change shipped, and why it made something run more often, run larger, or run somewhere it did not before. The answer sits in a repository, and the person who can read it is an engineer with that repository open. This post explains how CostReveal hands that engineer's coding agent the evidence, through its MCP server, and why CostReveal never reads the code itself.

The evidence CostReveal already has

For every anomaly, CostReveal works out three things from the bill and from each cloud's own records, by rules, the same every time:

  • What drove it: the day's move divided exactly by team, account, region, model, customer and every other dimension.
  • What moved: the usage types and resources that moved most below the service, how much was more use and how much a higher price, and what was new on the day or gone from it.
  • What changed: the changes made on the day and the day before, from CloudTrail, Azure's Activity Log, Google Cloud's audit logs and Kubernetes rollouts, those to a resource that moved first, each with who made it and when.

That is often enough to know where to look: a new instance, launched by a deploy role at 14:02, on the day a training job's spend tripled. It is not the commit.

Why the agent, not CostReveal, reads the code

Reading a customer's repositories would mean asking for source access a security review rightly refuses, sending code to a model, and guessing at intent. A coding agent the engineer already runs, such as Claude Code, Cursor or Visual Studio Code's agent, has the repository open with the engineer's own access, under their company's own rules. What it lacks is the evidence. So CostReveal gives it the evidence, and the agent reads the history.

How the agent gets the evidence

CostReveal's MCP server follows the Model Context Protocol, which these tools speak. The engineer adds the server's address to the tool and approves it in CostReveal when it asks; the agent then reads as them, with their role and only the projects they may see, through fifteen read only tools, each answering exactly as its API endpoint does, with the same checks: the month's spend by any dimension, what drove a change, forecasts and anomalies, and for an anomaly its drivers, its movements and its changes. It can change nothing.

A session might go like this. The engineer asks: "Read CostReveal's anomalies for this month, take the largest, and find the commit in this repository that explains it." The agent calls get_insights and finds the anomaly in EC2 on the 10th. It calls get_anomaly_movements and learns that one instance type's hours tripled, from a resource new that day. It calls get_anomaly_changes and learns that RunInstances launched that resource at 14:02 UTC, by the deploy role. Then it reads the repository's history around that time, finds the change to the training job's instance count merged that morning, and shows it, with the evidence it rests on.

One install

CostReveal's plugin for Claude Code and Codex adds the MCP server and skills that walk the agent through these steps, so the question above is enough. In Claude Code: /plugin marketplace add CostReveal/costreveal-agents, then /plugin install costreveal@costreveal, and sign in from /mcp; in Codex, codex plugin marketplace add CostReveal/costreveal-agents. Beside investigating a spike, its skills explain a month's change, list the anomalies to look at, forecast against budgets, rank what spend goes to, measure attribution coverage, triage savings, and set a pull request's cost drivers beside what they cost today. It is open source, so a security review can read exactly what it asks the agent to do.

What stays true

  • The figures are CostReveal's own: amounts are exact decimal strings, each with its basis, never recomputed by the agent.
  • What changed is evidence matched to the spike by rules, never stated as its cause, and so is the commit the agent proposes. The engineer decides.
  • CostReveal never sees the code, and the agent reads only what the engineer may, changing nothing. Disconnecting it under Connected apps ends its access at once.

Frequently asked questions

Which AI tools can connect? Any that connects to a remote MCP server and signs in with OAuth, such as Claude Code, Cursor and Visual Studio Code; Claude Code and Codex also have CostReveal's plugin, and ChatGPT reaches the server as a custom connector. The setup for each is in the docs.

Do I need the plugin? No. The MCP server gives every AI tool the same figures, signed in as you. The plugin, for Claude Code and Codex, adds skills that take the agent through the evidence in the same order every time, ending at the commit.

Does CostReveal read my repository? No. The agent you run reads it, with your own access; CostReveal answers only about figures and changes.

Can the agent change anything in CostReveal? No. Every tool only reads.

What does it need from me? The server's address in your tool, and your approval in CostReveal when it asks. A script that cannot sign in can use a read only API key instead.

Keep reading