DEV Community

Ofer Shapira
Ofer Shapira

Posted on

I Built a Cursor Plugin to Track My Team's AI Spend From the IDE

I manage a Cursor Enterprise team with 50+ developers. AI spend has become the new cloud cost problem, except there's no Datadog for it. You find out about cost spikes when the invoice lands, weeks after the damage is done.

Cursor has an admin dashboard, but it shows raw numbers. It doesn't answer questions like "why did our spend jump 40% last Tuesday?" or "who switched to Opus and tripled their daily cost?"

So I built a Cursor plugin that wraps the Cursor Enterprise API as MCP tools, so my AI agent can answer those questions for me, right in the IDE.

A Cursor MCP server for enterprise usage and spending data

cursor-usage is a Cursor plugin (also works with Claude Code) that exposes the full Cursor Enterprise Admin and Analytics APIs through the Model Context Protocol (MCP). If you're not familiar with MCP, it's the standard that lets AI agents call external tools. In this case, the "tools" are your team's spending and usage data.

You install the plugin, set your API key, and start asking questions in natural language.

It includes:

  • An MCP server with 15 tools covering team members, spending, daily usage, billing groups, per-request events, DAU, model adoption, agent edits, tabs, MCP usage, and more
  • Two skills that teach the agent how to interpret Cursor Enterprise data correctly and how to optimize AI costs
  • Commands for quick access: /usage-report, /spend-check, /model-audit
  • Composite tools like get_team_overview and get_user_deep_dive that combine multiple API calls into a single useful answer

Install is one line:

/add-plugin cursor-usage
Enter fullscreen mode Exit fullscreen mode

Or if you prefer manual MCP server setup, it's just an npx command in your config:

{
  "mcpServers": {
    "cursor-usage": {
      "command": "npx",
      "args": ["-y", "cursor-usage-mcp"],
      "env": {
        "CURSOR_API_KEY": "your-api-key-here"
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Understanding the Cursor Enterprise API gotchas

Anyone can call REST endpoints. The real work was figuring out what the numbers actually mean, because the Cursor API data is misleading without context. Here are some of the gotchas I ran into:

totalLinesAdded is not an AI productivity metric. It includes manual edits, tab completions, and agent-generated code all lumped together. If you want to know how much code AI actually contributed, you need acceptedLinesAdded. And even that's incomplete because agent mode auto-applies changes, so those lines don't show up in the acceptance count.

spendCents includes the subscription amount. A user showing $50 in spendCents with $40 in includedSpendCents only has $10 in actual overage. I've seen people freak out about a user "spending $200" when most of it was covered by the plan.

A single user switching from Sonnet to Opus can 10x their daily spend. Premium models like Opus and GPT-5 cost roughly 10-50x more per request than standard models like Sonnet or GPT-4o. One developer experimenting with Opus for a day can look like a cost anomaly.

Spend limits don't mean what you think. Setting a hard limit of $0 means "no overage allowed," not "no usage allowed." The user can still use their included allocation.

The acceptance rate formula is wrong if you use the obvious one. acceptedLinesAdded / totalLinesAdded is misleading because the denominator includes manual edits. The real AI acceptance rate is totalAccepts / totalApplies.

These gotchas are now encoded in the plugin's skills, so the agent knows about them before it even looks at your data. When someone asks "are we getting value from AI?", the agent knows to check acceptance rates (healthy teams see 40-70%) and cross-reference with model costs, not just report raw line counts.

Architecture: why a local MCP server, not a hosted service

A few choices I made and why:

stdio MCP, not HTTP. The server runs locally on the user's machine. No hosted service, no data leaving your network. You provide your own API key. This was important because the data includes individual developer spending and usage patterns. Unlike hosted solutions like Vantage, your data never touches a third-party server.

Zod validation on all inputs. Every tool validates its arguments with Zod schemas. Dates must be ISO format, emails must be valid, page sizes have bounds. The agent can't accidentally send garbage to the API.

Composite tools for common queries. Instead of making the agent figure out that "give me a team overview" requires calling 4 different endpoints, get_team_overview does it in one call. Same for get_user_deep_dive. These save tokens and reduce the chance of the agent getting confused mid-chain.

Cross-platform from day one. The plugin works as a Cursor marketplace plugin, a Claude Code plugin, or standalone via npx. The MCP server is the same regardless of which client runs it.

From quick questions to a full AI cost management dashboard

The plugin is great for quick questions, but it has limits. The Cursor API only goes back 30 days for analytics. You can't do anomaly detection in a chat window. You can't set up automated alerts.

That's where cursor-usage-tracker comes in. It's the full open-source dashboard I built for the same problem: automated data collection, three-layer anomaly detection (thresholds, z-score, and trend analysis), Slack and email alerts, incident lifecycle tracking with MTTD/MTTI/MTTR, and a web UI with charts.

The plugin is the quick entry point for Cursor Enterprise cost tracking. When you hit its limits, the dashboard is there. They work together or separately.

Getting started with cursor-usage

  1. Install: /add-plugin cursor-usage (or manual MCP setup above)
  2. Set your Cursor Enterprise Admin API key
  3. Ask questions: "How much did my team spend this week?", "Who's using the most expensive models?", "Run a model audit"

The skills and commands are included automatically with the plugin install.

What's next

  • Submitted to the Cursor marketplace
  • Planning to submit the analysis skill to anthropics/skills
  • Adding more composite tools based on feedback
  • Exploring the newer per-user analytics endpoints

If you're managing a Cursor Enterprise team and want to try it out, I'd love to hear what queries you find most useful.

Links:

Top comments (5)

Collapse
 
ben profile image
Ben Halpern

Clever!

Collapse
 
harsh2644 profile image
Harsh

The real challenge here isn't just tracking spend—it's the attribution logic when devs switch between models mid-session. How are you handling the cost allocation when someone starts with Haiku but escalates to Opus for complex reasoning? Would love to understand the data model behind this!

Collapse
 
matthewhou profile image
Matthew Hou

This is solving a real problem. AI spend visibility is a mess right now — every team I've talked to has at least one engineer who has no idea how much they're burning through because it all gets lumped into "infrastructure."

The IDE integration is smart. That's where developers actually are. A dashboard nobody opens vs. context that shows up where you work — obvious which wins.

What's your p95 latency on the spend calculation? Curious if it adds any noticeable delay to completions.

Collapse
 
harsh2644 profile image
Harsh

Smart solution! Cost observability at the IDE level is game-changing. Curious about your implementation — does it track per-project costs as well? This kind of granularity helps with both budgeting and optimizing model selection per use case.

Collapse
 
matthewhou profile image
Matthew Hou

This is a real problem that nobody's talking about enough. I tracked my own AI tool spending last month and it was $127/month across subscriptions and API credits. Most devs I know have no idea what they're actually spending.

Does your plugin track per-developer cost or just team aggregate? Curious if you can identify which types of tasks burn through the most tokens.