Skip to main content
Glama

CI Release npm License: MIT Stand With Ukraine

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

Context Tally side pane, light theme, grid view

Context Tally side pane, dark theme, bar view

Global dashboard (Dark, two-column layout):

Context Tally global dashboard, dark theme


Related MCP server: context-tree_monitor

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 a 200K long-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 stored conversations/<id>.db read-only through the built-in node:sqlite module (no npm runtime dependencies, no Python). The native TopLevelTokenGroup breakdown, 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:sqlite is unavailable, the file is missing, the schema changed, or the groups are untyped, Context Tally falls back to transcript.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) and dbStatus (ok, empty, read_failed, sqlite_unavailable, absent) drive one badge: Exact (DB), DB read failed, Transcript (Node), DB empty, Transcript (no DB) or DB 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 CHECKPOINT with and without embedded tokens, compaction savings (before → after), post_compaction state (updates on the next turn), empty chats (0%), and partial data 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 categoriesCoverage ratio reports how much of the prompt they cover. Token groups without a type are reported separately as unattributed (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-pane with 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/200K lines 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 CHECKPOINT in the cache card and the copied /context report.

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's size, mtime or -wal changes. cacheIndex is auto (default) or off.

  • Timeline (kind: "trace"): per-turn TTFT (f11), stream time (f12), model wait (f11 + f12) and tool time (f8 − f7 from step_type = 132), with inferred tool confidence and overlap counters. Autopsy (kind: "autopsy") lists checkpoint token deltas and a type#step_index diff between the main and full transcript — always inferred, 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 stay unknown and repeat detection stays off until S1 is verified.

  • Taxonomy (kind: "taxonomy"): eight group rows with their own ids, unattributed outside the rows, fail-closed on unknown group types. The five UI categories and SCHEMA_VERSION are unchanged.

Fast handoff ("Fake Compact")

  • Standard or Structural (no quotes) extraction, built locally by build_handoff_summary with 0 LLM tokens; SECRET_PATTERNS redaction shows a redacted-count badge.

  • Copy Handoff for any chat; Start new chat (aux_pane only) sends it via sendMessage with target: "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; truncated marks 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.

  • AlertStrip quick 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 behind getHostCapabilities(), therefore only in aux_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_time auto-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 unchanged replies 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 applyDocumentTheme and applyHostStyleVariables.

  • WCAG AA contrast targets, keyboard navigation, role="progressbar" with an accessible name, aria-pressed toggles and a lang attribute 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.0 for building. Exact database numbers require Node ≥ 22.13.0: on 22.12.0 node:sqlite is still hidden behind --experimental-sqlite. Node 20.19 runs the transcript fallback and shows a Transcript (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 reports multi_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.zip

  • SHA256SUMS.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

  1. Open Customizations → Installed, find Context Tally and enable it.

  2. Open the side pane from + (the aux_pane surface) or the Plugins tab (global). Both work with an empty {} tool input.

  3. To use the inline surface, 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 calls show_context_inline and 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.jsonl and transcript_full.jsonl;

  • ~/.gemini/antigravity/annotations/*.pbtxt — conversation titles and last_user_view_time;

  • ~/.gemini/antigravity/conversations/<id>.db — opened with readOnly: 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 strict default-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)

  1. discovery.ts parses annotations/*.pbtxt for titles and last_user_view_time, filters subagents, and sorts chats with a strict last_user_view_time priority.

  2. transcript.ts incrementally parses transcript.jsonl (Gen 1/2/3), honours CHECKPOINT boundaries and compaction savings, and resolves media attachments.

  3. db_reader.ts optionally enriches the snapshot from SQLite (model, budget, native token groups); config_reader.ts estimates skills and MCP tool weight (Lazy by default, Eager only for configured servers).

  4. breakdown.ts merges both sources into a schemaVersion: 1 payload: five categories summing to 100%, Dual Cap limits, cache metrics, compaction stats, Top-5 heavy steps and a revision hash for unchanged polling. handoff.ts builds the on-demand redacted Markdown handoff within a byte limit (inline ≤ 1 040 384 B, CallToolResult ≤ 1 048 576 B). diagnostics.ts serves the lazy drill-downs, what_if, the anonymized env dump and the v0.6.0 kinds.

  5. index_cache.ts / corpus.ts persist and read the on-demand corpus index; trace.ts / autopsy.ts, cache_dynamics.ts / waste.ts, unused.ts / skill_tax.ts and taxonomy.ts build the diagnostics payloads, all app-only and lazy.


License

MIT — see LICENSE.

Available Tools

6 tools
build_handoff_summaryBuild Context Handoff SummaryB

Build a redacted, ready-to-paste Markdown handoff of the current conversation on explicit user request.

Inputs: mode, scope, locale, memberId, +2 more.

get_context_diagnosticsContext Tally DiagnosticsC

Return lazy data for the selected conversation: category drill-down, prompt-cache drops, the What-If savings catalog, an efficiency verdict, or an anonymized environment dump.

Inputs: kind (required), categoryId, conversationId.

get_corpus_overviewContext Tally CorpusB

Return the on-demand overview of every conversation database: totals, models and index state. App-only and never polled.

Inputs: refresh.

refresh_context_usageRefresh Context TallyB

Return a fresh Context Tally snapshot, or a lightweight unchanged marker when the revision matches.

Inputs: lastRevision, conversationId.

save_view_settingsSave Context Tally SettingsC

Persist Context Tally settings (language, surfaces, overrides, eager MCP servers, pinned chat) and return a fresh snapshot.

Inputs: alerts, language, surfaces, cacheIndex, +6 more.

show_context_usageContext TallyC

Open the Context Tally panel showing context window usage, category breakdown, and cache hit rates.

Inputs: conversationId.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 6 tools

    Disambiguation4/5

    Most tools are cleanly separated by resource and action: viewing usage, refreshing usage, diagnostics, corpus overview, handoff export, and settings persistence. The main risk is show_context_usage vs refresh_context_usage, which both concern the same Context Tally panel and could be misselected, and get_context_diagnostics is a fairly broad multi-purpose entry point (drill-down, cache drops, what-if catalog, verdict, env dump) selected by a mode parameter.

    Naming Consistency5/5

    Every tool follows the same snake_case verb_noun convention (show_, refresh_, build_, get_, save_) with a clear resource qualifier. Verb choices are semantically meaningful and predictable, so an agent can infer sibling tools by analogy.

    Tool Count5/5

    Six tools is well-scoped for a context-usage inspection server; each tool covers a distinct surface (view, refresh, diagnostics, corpus, handoff, settings) with no filler. Nothing appears redundant or missing at the count level.

    Completeness4/5

    The surface covers the full inspection lifecycle: live panel, refreshed snapshots, deep diagnostics, cross-conversation corpus, handoff export, and settings write. The only minor gaps are no explicit reset/clear-settings or settings-read operation, and no explicit close/hide for the panel, which agents can work around via the snapshot-returning tools.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      An Antigravity MCP App plugin that surfaces real-time context window occupancy, remaining tokens, prompt cache hit rate, output speed, rolling 5-hour/7-day quota usage, and a 28-day activity heatmap by read-only parsing of local transcript logs. It presents these metrics in a theme-aware sidebar dashboard without patching or injecting into the host client.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables users to view live session context window occupancy, step-by-step growth charts, and compaction thresholds alongside a GitHub-style daily token usage heatmap with per-day, per-model, and per-session breakdowns and persistent filters. All data is read strictly read-only from local Antigravity transcripts with no network calls, telemetry, or token overhead.
      MIT