[KongchangAI]
· 3 min read· 1,523 words

AI Agent Context Audit: 90K Tokens Burned Before the First Message

AI Agent Context Audit: 90K Tokens Burned Before the First Message

Developer builds ctxvitals to quantify 92,413 tokens of context waste and security risks AI agents burn before the first message.

Developer princejain756 found AI agents can burn tens of thousands of tokens before reading the user's first message, so he built ctxvitals. It launches every MCP server in your config, sends real initialize and tools/list requests, counts injected schema tokens, and scans skills, rules, and hooks across Claude Code, Cursor, Windsurf, and more. His self-audit: 901 skill descriptions occupying 39,402 tokens, 15 MCP servers burning 92,413 tokens per turn, grade F. Root causes included the same server configured three times and a single Read tool schema consuming 7,487 tokens. It also flags hardcoded secrets, curl|sh installers, prompt injection phrases, and unpinned npx/uvx packages.

An Overlooked Context Waste Crisis

A post on Reddit's r/mcp subreddit hit a nerve: run 15+ MCP servers, and your AI agent may consume 60,000 tokens before it ever reads the user's first message. The comments were full of patchwork fixes — lazy-loading tricks, homemade get-tool-help utilities, manually grepping /context output. But nobody had built a real diagnostic tool.

Developer princejain756 decided to do it himself, and ctxvitals was born. His self-audit results were shocking: 92,413 tokens burned before the first message.

AI agent context audit tool screenshot

What ctxvitals Actually Measures

According to the author's notes on GitHub, ctxvitals launches every stdio MCP server in your configuration, sends real initialize and tools/list requests, and counts the schema tokens each server actually injects into context.

It doesn't stop at MCP servers. The tool also scans the configurations of major AI coding tools — Claude Code, Cursor, Windsurf, Copilot, Codex, and Devin — tallying how many tokens each skill, rules file, command, and hook occupies. This cross-platform coverage makes it one of the few diagnostic tools that can produce a complete context picture.

MCP (Model Context Protocol) is an open protocol introduced by Anthropic in late 2024 to let AI agents connect to external tools, data sources, and services in a standardized way. Each MCP server declares its tool list to the client (via tools/list), along with metadata for each tool: name, description, parameter schema, and more. This metadata isn't loaded on demand — it's injected in full into the model's context window when the session initializes, and the model re-reads it on every inference pass. This means the more MCP servers you have and the more complex their tools, the more tokens are permanently occupied, shrinking the window available for actual conversation and file content.

MCP supports two transport modes: stdio (communicating with a local process via standard input/output) and SSE/HTTP (remote connections). ctxvitals primarily audits stdio, since it's the most common local configuration and most prone to duplicate registration and version drift across tools.

The Author's Audit Results: An F Grade

The author published his own audit data, and every line is worth checking against your own setup:

MetricValue
Skills installed901
Skill description tokens (always loaded)39,402
MCP servers15
Tokens burned per conversation turn92,413
GradeF

What's really embarrassing isn't the number itself — it's the reasons behind it:

  • The same MCP server configured three times under three different names — paying three times the token cost for one schema
  • A plaintext API key sitting brazenly in an environment variable block
  • A server pointing to a binary that no longer exists

Even more absurd: after the author shipped a per-tool ranking feature, he discovered that the schema for a single tool — claude-code's Read — consumed 7,487 tokens. One tool. Over seven thousand tokens.

"Skills" are an extension mechanism introduced by tools like Claude Code, typically stored as Markdown or YAML files that define instructions, rules, or behavior templates the agent can auto-load. The critical problem: skill descriptions are always loaded by default, whether or not the skill is actually used in the current session. 901 skills means 901 description blocks permanently resident in context, which is exactly where the 39,402 tokens come from.

Similar mechanisms include rules files (like .cursorrules, CLAUDE.md), commands, and hooks — all injected at session startup. Individually they look cheap, but the cumulative effect is dramatic. ctxvitals measures them separately precisely so users can see the real context bill behind "capability expansion."

Security Risks: Not Just Wasted Tokens

ctxvitals's second core capability is security checking. It scans configuration files, skill files, and MCP configs for:

  • Hardcoded secrets: plaintext passwords and API keys written directly into configs
  • Data exfiltration patterns: credential storage and network calls appearing in the same file — highly suspicious
  • curl | sh installers: installation methods that pipe scripts directly from the network into execution
  • Prompt injection phrases: text that could be maliciously exploited to hijack agent behavior
  • Unpinned npx/uvx packages: supply chain risk from version drift
  • Duplicate registrations pointing to different binaries: the same tool name registered by multiple servers — which one actually gets called depends on load order, a veritable supply chain roulette

These checks cover the most common security blind spots in AI agent configurations. The duplicate registration problem is especially easy to overlook in team projects or long-maintained codebases, but the consequence could be the agent executing unintended code.

curl | sh installers are installation methods that pipe a remote script directly to the shell for execution, e.g. curl -fsSL https://example.com/install.sh | sh. The risk: you can't review the script's contents before execution, the server can return different code at any moment, and there's no version checksum or signature verification. For components like MCP servers that have filesystem access and network call permissions, a single tampered install script can lead to credential leaks or persistent malicious code.

Unpinned npx/uvx packages refers to configurations that hardcode a package name without specifying an exact version (like npx some-mcp-server instead of npx [email protected]). On each launch, the package manager may pull the latest version — meaning a breaking upstream update or a hijacked release lands directly in your agent's runtime environment. This is one of the most common entry points for supply chain attacks, and AI agent configs are notably lacking in version-pinning awareness.

How to Use ctxvitals

Getting started is simple — zero dependencies, requires Node 18+:

npx ctxvitals

Supported flags include:

  • --html report.html: generate a shareable HTML report
  • --json: output JSON for easy pipeline processing
  • --no-probe: if you don't want it to actually launch servers
  • A built-in Claude skill that lets the agent self-audit

The project is open source at github.com/princejain756/ctxvitals.

Why Every AI Agent User Should Care

The author's audit exposes a structural industry problem: AI agent tools lack visibility into context cost.

When you install a skill, add an MCP server, or configure a rules file, what you see is "I have one more capability." What you don't see is "I'm burning a few thousand more tokens." When these configs pile up into the dozens or hundreds, the context window gets filled with background-loaded schemas and descriptions, severely compressing the space left for actual conversation.

This is fundamentally different from traditional software performance optimization. Traditional app performance issues show up directly as lag and crashes — users feel them. AI agent context waste is silent — you just feel like the model "seems dumber," "answers more slowly," or "can't remember context," but it's hard to trace the root cause.

ctxvitals's value is that it quantifies the problem. For the first time, you can see clearly: before your agent even starts working, exactly how heavy a burden is it carrying?

The question the author poses at the end is worth every practitioner's consideration: How many tokens is your stack burning? He's seen 92k — he wants to know where the ceiling is.

If your agent config has accumulated a substantial number of skills and MCP servers, spend a few minutes running npx ctxvitals. The results might make you rethink your configuration strategy.

A context window is the maximum number of tokens a model can process in a single inference pass, including system prompt, tool schemas, conversation history, and current input. Mainstream models currently support 128K to 200K tokens, which sounds like a lot — but when skill descriptions, MCP tool schemas, rules files, and other fixed overheads accumulate past 90K, more than half the space truly available for conversation and code analysis is gone.

More insidious still: the impact of context waste on model performance is non-linear. Research shows that as irrelevant content accumulates in context, the model's attention to key information degrades — the "lost in the middle" phenomenon, where information positioned mid-context is more easily overlooked. This means wasted tokens aren't just a cost issue — they're an accuracy and reasoning quality issue. ctxvitals's greatest value lies precisely in turning this invisible drain into a measurable number.

One-line Summary

Developer builds ctxvitals to quantify the 92,413 tokens of context waste and security risks AI agents consume before the first message.

Paragraph Summary

Developer princejain756 discovered AI agents can burn tens of thousands of tokens before reading the user's first message, so he built the diagnostic tool ctxvitals. It launches every MCP server in your config, sends real initialize and tools/list requests, counts the schema tokens each server injects into context, and scans skills, rules, and hooks across Claude Code, Cursor, Windsurf, and other major tools. His self-audit results: 901 skill descriptions occupying 39,402 tokens, 15 MCP servers burning 92,413 tokens per turn, grading an F. Root causes included the same server configured three times and a single Read tool schema consuming 7,487 tokens. ctxvitals also offers security checks covering hardcoded secrets, curl|sh installers, prompt injection phrases, unpinned npx/uvx packages, and duplicate registrations pointing to different binaries. Zero dependencies, runs on Node 18+.

#MCP server#AI agent context#token waste#ctxvitals#context window#Model Context Protocol#Claude Code#supply chain security
Share:

Related articles