Skip to main content
Glama

Context Lens

CI Release License: MIT Stand With Ukraine

English · Русский

Official MCP App (ui://) context window & prompt-cache monitor — Zero-RPC, Zero-OAuth, Zero-CDP, Zero-Python.

Context Lens 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-lens/app.html   →  dist/app.html   (single file, inlined CSS/JS)
tools: show_context_lens, refresh_context_lens, save_lens_settings

The default show_context_lens tool is app-only (visibility: ["app"]): the model never sees it, so the monitor costs 0 prompt tokens.

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 Lens side pane, light theme, grid view

Context Lens side pane, dark theme, bar view

Global dashboard (Dark, two-column layout):

Context Lens global dashboard, dark theme


Related MCP server: Cache Hit Monitor for Antigravity

Features

Dual Cap readout

Antigravity enforces two different limits, and Context Lens 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.

  • Transcript fallback — if node:sqlite is unavailable, the file is missing, or the schema changes, Context Lens 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).

  • 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 — always summing to 100%, with an Exact (DB) vs Estimated badge.

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

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

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, 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 Lens (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.12.0 for building. At runtime, any Node the app can launch works: node:sqlite is used when available (Node ≥ 22.5) and the transcript fallback otherwise.

  • No Python. No browser automation. No network access.


Installation (no curl | sh, no irm | iex)

1. Download

Grab both files from the Releases page of this repository:

  • context-lens-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-lens-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-lens-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-lens/

Windows

%USERPROFILE%\.gemini\config\plugins\context-lens\

Or let the CLI install the extracted folder:

agy plugin install ./context-lens

5. Enable and open

  1. Open Customizations → Installed, find Context Lens 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 Lens → MCP → Restart) and start a new chat.

Build from source

npm ci
npm run build     # dist/server.mjs + dist/app.html
npm run package   # release/context-lens-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 Lens 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. 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.


License

MIT — see LICENSE.

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables users to inspect real-time prompt cache hit rate, task throughput, and per-model token usage for Antigravity sessions and 5h/1d/7d windows through an interactive local dashboard. It combines lifecycle hook timing with local transcript data, with zero outbound network telemetry.
      MIT
    • 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