Context Anchor Anchors
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Why Context Anchor?
When long coding or research sessions hit token limits, automatic context compression summarizes raw history—often discarding exact file paths, subtle constraints, rejected approaches, and active task state.
Antigravity does not currently expose a PreCompact lifecycle hook or allow plugins to rewrite its internal compaction prompt. Context Anchor solves this within Antigravity's native plugin architecture by pairing:
Agent-Selected Context Anchoring (MCP Tools) — Gives the running agent first-class tools (
pin_context,unpin_context,list_pinned_context,get_pinned_context,replace_session_anchors) so the agent itself decides what must survive compression.Proactive Token & Compaction Watcher (Lifecycle Hooks) — Tails
transcript.jsonlonPreInvocationto warn the agent before auto-compaction hits, and automatically re-injects pinned anchors when a context drop is detected.Always-On Curation Rule &
/context-anchorSkill — Guides the agent to pin concise conclusions and exact pointers (never bloated raw logs), and lets you trigger manual curation at any time via/context-anchor.Zero Dependencies — Pure Node.js (
>= 18) standard library; works across Windows, macOS, and Linux withoutnpm install.
Related MCP server: mnemex
How It Works
flowchart LR
A[SessionStart / PreInvocation Hook] -->|Register session_id & tail transcript.jsonl| B{Token Check}
B -->|Tokens >= 80k| C[Inject Pre-Compression Nudge]
C -->|Agent curates important context| D[MCP: pin_context / replace_session_anchors]
D -->|Atomic JSON write| E[(Session & Workspace Anchors)]
B -->|Token drop >= 35% or step reset| F[Compaction Detected]
E -->|Priority sort: critical > high > normal| F
F -->|Inject systemMessage| G[Agent Continues Without Amnesia]Features & Components
1. MCP Server (anchors -> context-anchor_anchors)
Tool | Purpose |
| Pin or update a context anchor ( |
| Remove completed or obsolete anchors by |
| Inspect all active anchors with priorities, categories, and estimated token usage. |
| Retrieve the formatted survival bundle on demand. |
| Atomically deduplicate, merge, and replace all session anchors in one call. |
Supported categories: decision, constraint, state, file_map, pitfall, task.
Supported scopes:
session(default): Isolated to the currentconversationId.workspace: Persists across conversations in the same workspace directory.
2. Lifecycle Hooks (hooks.json)
SessionStart: Registers the activeconversationId, injectssession_id, and restores anyworkspace-scoped anchors.PreInvocation: Reads only the last 128 KB oftranscript.jsonl:Sends a non-spammy reminder when prompt tokens cross
80k(and every+40kthereafter).Detects compaction when a compaction/checkpoint step appears, step count resets, or prompt tokens drop by
>= 35%(and>= 10ktokens)—ignoring stale pre-compactionPLANNER_RESPONSEtoken telemetry so aCHECKPOINTnever double-triggers recovery—and injects preserved anchors ordered by priority along with a post-compaction core context recap instruction.
Stop: Updates session metadata cleanly without blocking turn completion.
3. CLI Fallback (scripts/cli.mjs)
For manual inspection or pre-existing sessions where MCP tools have not yet attached:
node ./scripts/cli.mjs pin --title "API Contract" --content "Keep v1 response shape." --priority critical --category constraint
node ./scripts/cli.mjs list
node ./scripts/cli.mjs get
node ./scripts/cli.mjs unpin --title "API Contract"Installation
Option 1: Install via Antigravity CLI (agy)
# Install directly from a local clone or GitHub repository URL
agy plugin install https://github.com/Over9rowth/context-anchorOption 2: Manual Local Installation (Antigravity App / IDE / CLI)
Copy or clone this repository into your global Antigravity plugins folder:
macOS / Linux:
git clone https://github.com/Over9rowth/context-anchor.git ~/.gemini/config/plugins/context-anchorWindows (PowerShell):
git clone https://github.com/Over9rowth/context-anchor.git "$env:USERPROFILE\.gemini\config\plugins\context-anchor"
Note: After installing, open a new conversation (or reload) so the MCP server
context-anchor_anchorsattaches its tool declarations to the session.
Usage
Automatic mode: Just work normally. The always-on rule (
rules/AGENTS.md) andPreInvocationhook nudge the agent to curate critical context as sessions grow, restore it once after compression, and automatically recap the restored core context at the start of the post-compaction reply.Recommended
/context-anchor->/compactflow:Type
/context-anchorto have the agent audit, deduplicate, and save key context anchors, then prompt you with a/compacthandoff.Type
/compactin chat to compact the conversation window (Antigravity restricts slash commands to direct user input, so plugins/agents cannot run/compactautomatically).Send any short follow-up (e.g.,
继续/continue)—context-anchorinjects your curated anchors and instructs the agent to briefly recap the restored core context before resuming work.
Natural language: Ask the agent directly, e.g., "Pin our current architecture decisions and modified files with
pin_context."
Configuration (Optional Environment Variables)
Variable | Default | Description |
|
| Token count at which the first pre-compression curation nudge fires. |
|
| Additional token growth required before another nudge fires. |
|
| Ratio threshold ( |
|
| Maximum character budget for auto-injected anchor recovery blocks. |
|
| Instructs the agent to briefly recap restored core anchors in its first reply after compaction recovery ( |
|
| Override where session and workspace anchor JSON files are stored. |
Development & Testing
Requires Node.js >= 18.0.0. No dependencies to install:
npm test
# or
node --test ./scripts/test.mjsLicense
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Private memory, scratchpads, context export/restore and task handoff for AI agents.
Durable, revision-pinned memory storage and retrieval for AI conversations.
Private-by-default, local-first memory/context/task orchestrator for MCP apps and agents.
Securely search and manage workspace context files for AI agents and teams.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides persistent context synchronization and memory management for AI agents across sessions and projects, including file indexing, bug tracking, spatial navigation, and agent-to-agent handoff coordination.9 npm3MIT
- AlicenseNot gradedqualityCmaintenanceProvides persistent, anchored memory for AI coding agents, binding every decision to specific lines of code and delivering relevant context just-in-time via the Model Context Protocol.1MIT
- AlicenseAqualityBmaintenanceEnables MCP-compatible clients to maintain a local-first long-term memory by recording decisions, facts, and preferences, retrieving relevant past context, consolidating entries, and anchoring local file paths.449 npmMIT
- AlicenseNot gradedqualityAmaintenanceEnables AI agents to persistently store and retrieve decisions, patterns, and knowledge across sessions, with workspace organization and semantic search so context survives restarts and compaction.17 npmMIT