context-tally
v0.9.0Context Tally — local context window breakdown and prompt-cache monitor for Antigravity and MCP Apps hosts.
Context Tally is a local, read-only MCP App for the Antigravity App. It shows how full your context window really is, where the prompt tokens go, and how well the prompt cache is working — without a sidecar server, browser automation, OAuth proxying, or any Python dependency. It ships as one MCP server (stdio) plus one HTML bundle: All six tools — show_context_usage, refresh_context_usage, save_view_settings, get_context_diagnostics, build_handoff_summary and get_corpus_overview — are app-only (visibility: ["app"]): the model never sees them, so their tool schemas cost 0 prompt tokens.
Summary extracted from the README.
English · Русский
Local MCP App (ui://) context window & prompt-cache monitor — Zero-RPC, Zero-OAuth, Zero-CDP, Zero-Python.
Context Tally is a local, read-only MCP App for the Antigravity App. It shows how full your context window really is, where the prompt tokens go, and how well the prompt cache is working — without a sidecar server, browser automation, OAuth proxying, or any Python dependency.
It ships as one MCP server (stdio) plus one HTML bundle:
ui://context-tally/app.html → dist/app.html (single file, inlined CSS/JS)
tools: show_context_usage, refresh_context_usage, save_view_settings
get_context_diagnostics (app-only: category | cache | what_if | env |
trace | autopsy | cache_dynamics | waste | unused |
skill_tax | taxonomy)
build_handoff_summary (app-only, on-demand; no tool-schema tokens)
get_corpus_overview (app-only, on-demand; writes the index only when opened)
All six tools — show_context_usage, refresh_context_usage, save_view_settings,
get_context_diagnostics, build_handoff_summary and get_corpus_overview — are
app-only (visibility: ["app"]): the model never sees them, so their tool schemas
cost 0 prompt tokens. The MCP server header itself is a separate, measured mcp_servers
group (type 4); the payload exposes it as serverHeaderTokens and
scripts/measure-server-tokens.mjs prints it for one database. build_handoff_summary
and get_corpus_overview are invoked strictly on demand by an explicit user action and
never in the background. Prompt tokens are only added by the opt-in inline card
(show_context_inline, off by default).
Screenshots
Synthetic captures with sample English data (no real conversation text). The auxiliary pane in Light (10×10 grid) and Dark (stacked bar), followed by the full-width global dashboard.
| Light — 10×10 grid | Dark — stacked bar |
|---|---|
![]() |
![]() |
Global dashboard (Dark, two-column layout):

Features
Dual Cap readout
Antigravity enforces two different limits, and Context Tally shows both:
- Compaction budget — the effective
request_budget_tokens/ checkpointer limit at which history is compacted (CHECKPOINT). - Native window — the model's full context window (e.g.
1M), with a200Klong-context tier mark.
The header shows usage and percentage (e.g. 284.5K / 512K (55.6%)) alongside a
Native window badge and lets you switch between the two scales; a tick marks where
compaction begins.
Hybrid data engine (exact DB → transcript fallback)
exact_db— reads the locally storedconversations/<id>.dbread-only through the built-innode:sqlitemodule (no npm runtime dependencies, no Python). The nativeTopLevelTokenGroupbreakdown,request_budget_tokens, checkpointer limit, usage counters and the model name come straight from the database. Numbers are only labelled exact when typed groups cover the prompt and the schema guard passes.- Transcript fallback — if
node:sqliteis unavailable, the file is missing, the schema changed, or the groups are untyped, Context Tally falls back totranscript.jsonl, supporting all three known generations (Gen 1 without tokens, Gen 2 without a model field, Gen 3 with tokens + model).dataMode(exact_db/transcript_fallback) anddbStatus(ok,empty,read_failed,sqlite_unavailable,absent) drive one badge:Exact (DB),DB read failed,Transcript (Node),DB empty,Transcript (no DB)orDB groups missing. - Reading boundary: the active conversation plus its direct children (at most 25, read lazily for their token counts). The rest of the corpus is never scanned during polling; the full corpus is read only when you open the Corpus panel (on demand).
- Handles
CHECKPOINTwith and without embedded tokens, compaction savings (before → after),post_compactionstate (updates on the next turn), empty chats (0%), andpartialdata for logs over 4 MiB without a checkpoint.
Two honest cache metrics
- Last turn cache hit — the hit rate of the most recent request.
- Active window average — the cache share across the active window after the last
CHECKPOINT.
Five categories, two visualisations, Top-5 heavy steps
- Categories: messages, MCP tools, skills, meta context, system base — the five rows
add up to the typed database groups; a
categoriesCoverageratio reports how much of the prompt they cover. Token groups without a type are reported separately asunattributed(never as a sixth category), and rows carry Exact / Est. badges plus a provenance tooltip (source, basis, groups covered, data time). - Segmented bar ↔ 10×10 dot grid toggle; both describe the same numbers.
- Top-5 heaviest steps with redacted metadata only (step index, kind, redacted label, token count).
Category drill-down
- Click a category for a lazy inspector via app-only
get_context_diagnostics(no tool-schema tokens), with Exact / Est. badges and a mismatch note. - Workspace rules/instructions are detected; Open file uses
toggle-aux-panewith a clipboard path fallback.
Delta, growth and burn rate
- Step delta badge (
+X/-X, redacted driver tooltip) and a pure-SVG growth sparkline with compaction/200Klines and spike markers. - Rolling-median burn rate: tokens per step, tokens per turn, estimated steps left.
Cache diagnostics and session totals
- Click the cache card for sharp drops (≥ 15 pp, or < 50% after a
CHECKPOINT), explained by exact causes (checkpoint compaction, model switch) or heuristic ones (a ≥ 5-minute pause — the provider TTL is not proven — config change, system message, prefix shift). - Whole-session tokens and cache savings survive
CHECKPOINTin the cache card and the copied/contextreport.
Corpus history, timeline and hygiene (v0.6.0)
- Corpus (app-only
get_corpus_overview): open it to see every conversation database, tokens and models. The index is written only on that click, never at startup or in polling; a second open reuses the saved entries (decoded: 0) until a database'ssize,mtimeor-walchanges.cacheIndexisauto(default) oroff. - Timeline (
kind: "trace"): per-turn TTFT (f11), stream time (f12), model wait (f11 + f12) and tool time (f8 − f7fromstep_type = 132), withinferredtool confidence and overlap counters. Autopsy (kind: "autopsy") lists checkpoint token deltas and atype#step_indexdiff between the main and full transcript — alwaysinferred, never an invented "compaction event". - Hygiene (
kind: "waste" | "unused" | "skill_tax"): large tool results (≥ 4 000 tokens), declared-vs-observed tools and servers, and exact vs estimated skill cost. Skills stayunknownand repeat detection stays off until S1 is verified. - Taxonomy (
kind: "taxonomy"): eight group rows with their own ids,unattributedoutside the rows, fail-closed on unknown group types. The five UI categories andSCHEMA_VERSIONare unchanged.
Fast handoff ("Fake Compact")
- Standard or Structural (no quotes) extraction, built locally by
build_handoff_summarywith 0 LLM tokens;SECRET_PATTERNSredaction shows a redacted-count badge. - Copy Handoff for any chat; Start new chat (aux_pane only) sends it via
sendMessagewithtarget: "new"and falls back to the clipboard. - Ask chat for AI summary with 70-85% fill guidance, while the request still fits before compaction.
- The payload is bounded by bytes, not characters: the inline Markdown ≤ 1 040 384 B
and the whole
CallToolResult≤ 1 048 576 B;truncatedmarks a line-boundary cut.
What-If optimizer
- Read-only simulation via
get_context_diagnostics(kind: "what_if"): disable whole plugins (skills + MCP servers, without double-counting), individual MCP servers, skills and rule/meta files, or switch Lazy ↔ Eager schemas. - Instant projected savings and prompt share, plus copy-name and open-file (through
toggle-aux-pane) shortcuts. Nothing is applied; only local estimates change.
Threshold alerts and broken-cache detector
- Configurable in Settings and persisted in
settings.json: compaction warning %, the 200K long-context tier, heavy step delta, and a broken cache below threshold for 2+ consecutive steps. AlertStripquick actions (Build handoff, Cache details, Inspect messages) plus a compact alert badge in the header.
Copy diagnostic info
- A one-click footer button (
get_context_diagnostics,kind: "env") copies a strictly anonymized dump: versions, OS/arch, breakdown source, SQLite table names and counts. - Zero paths, usernames, titles, IDs or names — ready to paste into an issue report.
The compact inline card hides these diagnostic blocks and keeps background polling
disabled.
Three surfaces from one bundle
| Surface | Default | Prompt tokens | Notes |
|---|---|---|---|
aux_pane (side pane, opened from +) |
on | 0 | Supports Attach context summary |
global (Plugins tab) |
on | 0 | Full-width dashboard; no chat actions |
inline (opt-in card) |
off | adds one tool description | Enable in settings, then restart the MCP server and start a new chat. The compact snapshot card is not attached to every reply: it renders on request in the chat (e.g. "show context" → show_context_inline) |
In the inline surface every interactive panel — Handoff, What-If, the alert strip
and the footer diagnostic button — stays hidden, and polling stays disabled.
Native MCP App capabilities
- Copy
/context— a compact, redacted report for the clipboard. - Attach context summary — uses
app.updateModelContext()(strictly gated behindgetHostCapabilities(), therefore only inaux_pane) to attach the remaining tokens before compaction, the breakdown, cache metrics and Top-5 heavy steps to the next message. Ideal for handoff workflows before a compaction. - Strict
last_user_view_timeauto-follow — the monitor follows the chat you actually opened, not a background generation; subagents are isolated. - Pin a chat — lock the monitor to one conversation; unpinning resumes auto-follow immediately.
- Idle-backoff polling — 3 s while data changes, backing off to 15 s on
unchangedreplies or transient poll errors, paused while the view is hidden, at most one request in flight.
Localisation and accessibility
- EN / RU UI, switchable in the settings drawer and persisted server-side.
- Light / Dark host theming via
applyDocumentThemeandapplyHostStyleVariables. - WCAG AA contrast targets, keyboard navigation,
role="progressbar"with an accessible name,aria-pressedtoggles and alangattribute kept in sync.
Architecture and security comparison
The table describes the common architecture of publicly documented monitor tools. Individual projects differ; the wording is factual and not a recommendation against any particular tool.
Context Tally (MCP App ui://) |
Sidecar + LS RPC monitors | CDP / OAuth / proxy monitors | |
|---|---|---|---|
| Integration standard | Documented MCP App resource + app-only tools | Internal, undocumented Language Server RPC | Browser DevTools Protocol / injected scripts |
| Local HTTP port | None (MCP over stdio) | Usually a localhost HTTP endpoint | Usually a localhost proxy |
| Internal LS RPC | No | Yes | Sometimes |
| CDP / DOM injection | No | No | Yes |
| OAuth / proxy | No | No | Typically yes |
| Python required | No | Often | Sometimes |
| Exact DB breakdown + transcript fallback | Yes (node:sqlite read-only + Gen 1/2/3 JSONL) |
Varies by implementation | No (UI scraping) |
| Prompt token overhead (default) | 0 | Varies | Varies |
Requirements
- Antigravity App with MCP Apps support (
v2.34.0+). - Node.js
^20.19.0 || >=22.13.0for building. Exact database numbers require Node ≥ 22.13.0: on 22.12.0node:sqliteis still hidden behind--experimental-sqlite. Node 20.19 runs the transcript fallback and shows aTranscript (Node)badge instead of exact database rows. It can still read a saved corpus index created on a newer Node; without one, the Corpus panel reportsmulti_session_disabled. - No Python. No browser automation. No network access.
npm package
The MCP server is also published as context-tally.
The package ships the same dist/server.mjs and ui://context-tally/app.html bundle:
npx context-tally --data-dir=/path/to/data
It is intended for MCP Apps-capable hosts and local debugging. Antigravity users should
still install the plugin archive below: the app owns ${PLUGIN_DATA} and the plugin
surfaces, which a bare npm package cannot provide.
Installation (no curl | sh, no irm | iex)
1. Download
Grab both files from the Releases page of this repository:
context-tally-vX.Y.Z.zipSHA256SUMS.txt
2. Verify the checksum
macOS / Linux:
sha256sum -c SHA256SUMS.txt
# macOS builds without GNU coreutils:
shasum -a 256 -c SHA256SUMS.txt
Windows PowerShell:
$expected = (Get-Content .\SHA256SUMS.txt).Split(" ")[0]
$actual = (Get-FileHash .\context-tally-vX.Y.Z.zip -Algorithm SHA256).Hash.ToLower()
if ($actual -eq $expected) { "checksum OK" } else { "CHECKSUM MISMATCH" }
3. Pre-audit without executing anything (optional)
agy plugin validate --strict reads the manifest and bundle without installing or
running code:
agy plugin validate --strict ./context-tally-vX.Y.Z.zip
On Windows the CLI usually lives at %USERPROFILE%\.gemini\bin\agy.exe.
4. Install
Extract the archive into the plugins directory:
| Platform | Path |
|---|---|
| macOS / Linux | ~/.gemini/config/plugins/context-tally/ |
| Windows | %USERPROFILE%\.gemini\config\plugins\context-tally\ |
Or let the CLI install the extracted folder:
agy plugin install ./context-tally
5. Enable and open
- Open Customizations → Installed, find Context Tally and enable it.
- Open the side pane from
+(theaux_panesurface) or the Plugins tab (global). Both work with an empty{}tool input. - To use the
inlinesurface, enable it in the settings drawer inside the widget, then restart the MCP server (Customizations → Installed → Context Tally → MCP → Restart) and start a new chat. The card is not attached to every reply automatically: ask the agent to show the context (for example "show context"), which callsshow_context_inlineand renders a compact snapshot card at that point in the chat.
Build from source
npm ci
npm run build # dist/server.mjs + dist/app.html
npm run package # release/context-tally-vX.Y.Z.zip + release/SHA256SUMS.txt
npm test
npm run package writes a deterministic archive and its sha256sum-compatible
SHA256SUMS.txt (two spaces between hash and name, LF line ending).
Privacy and disclaimer
Context Tally reads only what is already stored on your machine, in read-only mode:
~/.gemini/antigravity/brain/**—transcript.jsonlandtranscript_full.jsonl;~/.gemini/antigravity/annotations/*.pbtxt— conversation titles andlast_user_view_time;~/.gemini/antigravity/conversations/<id>.db— opened withreadOnly: true;~/.gemini/config/**—GEMINI.md, config, skills and MCP server settings (to estimate tool/skill weight).
It makes zero network calls, has no telemetry, never touches OAuth tokens or
cookies, and never switches accounts. Local writes are limited to settings.json (plus a
best-effort settings.json.bak when salvaging a corrupt settings file) and files inside
${PLUGIN_DATA}:
corpus-index.json— written only when the Corpus panel is opened; it holds counts, model names and token-group numbers, never message text;handoff/*.json— oversized handoff bundles, written on demand. These files do contain edited message text: the redacted per-member summary and transcript. Secret-like patterns (SECRET_PATTERNS) are masked before the write, only the five newest bundles are kept (older ones are rotated out), and the widget never reads the files back — the strictdefault-src 'none'CSP forbids it, so the panel only shows and copies the path;- a short-lived
.index-probe, created and removed to test that${PLUGIN_DATA}is writable.
Media URI reads are strictly scoped to the conversation/brain root (blocking UNC paths
and symlink escapes). Secret-like patterns (SECRET_PATTERNS) are redacted before any
text leaves the server process. The widget iframe receives counts, shares and redacted
labels only — never raw message text. The clipboard report and the attached
model-context summary are built from the same redacted metadata.
This is an independent MIT project. It is not affiliated with, endorsed by, or supported by Google. Antigravity is a product of Google LLC; the name is used only to describe compatibility. The plugin name and assets intentionally avoid Google or Antigravity branding.
Data pipeline (short version)
discovery.tsparsesannotations/*.pbtxtfor titles andlast_user_view_time, filters subagents, and sorts chats with a strictlast_user_view_timepriority.transcript.tsincrementally parsestranscript.jsonl(Gen 1/2/3), honoursCHECKPOINTboundaries and compaction savings, and resolvesmediaattachments.db_reader.tsoptionally enriches the snapshot from SQLite (model, budget, native token groups);config_reader.tsestimates skills and MCP tool weight (Lazy by default, Eager only for configured servers).breakdown.tsmerges both sources into aschemaVersion: 1payload: five categories summing to 100%, Dual Cap limits, cache metrics, compaction stats, Top-5 heavy steps and a revision hash forunchangedpolling.handoff.tsbuilds the on-demand redacted Markdown handoff within a byte limit (inline ≤ 1 040 384 B,CallToolResult≤ 1 048 576 B).diagnostics.tsserves the lazy drill-downs,what_if, the anonymizedenvdump and the v0.6.0 kinds.index_cache.ts/corpus.tspersist and read the on-demand corpus index;trace.ts/autopsy.ts,cache_dynamics.ts/waste.ts,unused.ts/skill_tax.tsandtaxonomy.tsbuild the diagnostics payloads, all app-only and lazy.
License
MIT — see LICENSE.

