agent-memory-mcp
Provides a Google Antigravity plugin bundle that enables zero-turn SessionStart context hydration and scoped agent rules, integrating persistent project memory into Antigravity.
agent-memory-mcp
Persistent, per-project architectural memory, centralized cross-project global knowledge graph, two-tier anti-loop dead-end tracking, and token budgeting middleware for AI coding agents.
Works with Google Antigravity, Claude Code, Cursor, Windsurf, Cline, and any MCP-compatible environment.
โก The Problem
AI coding agents suffer from session amnesia, debugging loops, and context bloat:
When a chat session terminates or context is compacted, the agent forgets project patterns, architectural decisions, and setup instructions.
When encountering errors, agents repeatedly attempt the same failing fix because past failure context is lost across sessions.
Proven patterns and library workarounds learned in one repository are forgotten when opening another repository.
Unbounded tool responses dump thousands of raw tokens into agent context windows, burning token budgets and degrading model reasoning.
Related MCP server: @renzynx/memory-mcp
โจ Features
๐ Zero External Database Setup: Built directly on Node.js 22.5+/24+ native
node:sqlitein WAL mode. No Docker, no Python, no native compilation dependencies.๐ Centralized Global Knowledge Graph: Store cross-project architectural patterns, library quirks, and conventions in
~/.ag-memory-mcp/global.db. Seamlessly promote project memories viapromote_to_globaland read withg-prefixed IDs.๐ก๏ธ Two-Tier Anti-Loop Dead-End Registry: Distinguish between immediate code/test bugs (
error_loop) and intentional architectural constraints (architectural). Track active constraints and reopen dead-ends viareopen_dead_endwhen requirements evolve.๐ฐ Output Token Budgeting Middleware: Automatically estimates tokens and gracefully caps oversized tool outputs at natural sentence and word boundaries. Configure via
AG_MEMORY_MAX_RESPONSE_TOKENSor~/.ag-memory-mcp/config.json, with emergencyfull_content: truebypass.๐ Ranked Full-Text Search (FTS5): Weighted BM25 search across titles, summaries, tags, and files with contextual snippets and Porter stemming for both project stores and global knowledge.
๐ Code-Anchored Context & Staleness Detection: Links notes to specific workspace files; warns the agent if referenced code was modified on disk after the memory was saved.
๐ Audit & Token Efficiency Metrics: Query machine-wide token savings and audit logs across projects via
get_token_metrics.๐ Zero-Data-Loss JIT Migration: Automatically detects, validates, and migrates legacy
.ag-memory.jsonfiles on first project open, creating verified backup archives.
๐๏ธ Architecture
flowchart LR
subgraph Clients["AI Clients & Editors"]
AG["Google Antigravity"]
CC["Claude Code"]
CU["Cursor / Windsurf"]
end
subgraph MCP["agent-memory-mcp Engine (15 Tools)"]
Server["MCP Server (JSON-RPC)"]
Middleware["Token Budgeting Middleware<br/>(Natural Sentence Trimming)"]
Migrator["Zero-Loss JIT Migrator"]
end
subgraph Storage["Central Data Vault (~/.ag-memory-mcp)"]
ProjectDB[("project-*.db<br/>(Project WAL + FTS5)")]
GlobalDB[("global.db<br/>(Cross-Project Knowledge & Audit)")]
Config["config.json"]
Backups["backups/"]
end
Clients <-->|"stdio"| Server
Server --> Middleware
Server --> Migrator
Migrator --> Backups
Server <--> ProjectDB
Server <--> GlobalDB
Server <--> Config๐ ๏ธ MCP Tools (15 Tools)
Project-Scoped Memory Tools (1โ10)
Tool | Mode | Description |
| Read-only | 1-shot check returning initialization state, architecture TOC, dead-end count, and recent session timeline in a single call. Auto-migrates legacy |
| Read-only | Chronological feed filterable by |
| Write/Upsert | Single or atomic batch ( |
| Read-only | Weighted FTS5 BM25 search across |
| Read-only | Reads single |
| Write | In-place partial update to |
| Write | Soft-archives obsolete memories ( |
| Write | Logs |
| Read-only | Searches recorded dead-ends by error message, keyword, or |
| Read-only | Returns all memories and dead-ends anchored to target |
Global Knowledge & Taxonomy Tools (11โ15)
Tool | Mode | Description |
| Write | Saves or updates a cross-project pattern, convention, or library quirk in |
| Read-only | Searches machine-wide patterns and library quirks using BM25 ranking, filterable by |
| Write | Promotes a proven project-specific memory node to the machine-wide global knowledge graph in |
| Write | Reopens a previously recorded dead-end with a justification when external constraints or library versions change. |
| Read-only | Queries machine-wide token savings, budgeting statistics, and audit logs across all projects from |
๐ง Deep Dives
๐ Cross-Project Global Knowledge Graph
When developing across multiple microservices or repositories, agents repeatedly discover common framework quirks (e.g., SQLite lock timeouts in Node.js, Next.js hydration issues, Docker networking gotchas).
Global notes are saved to
~/.ag-memory-mcp/global.db.Project memories can be promoted to global status via
promote_to_global.Any global node can be read using
read_memory_nodewith itsg-...ID prefix.
๐ก๏ธ Two-Tier Anti-Loop Dead-End Taxonomy
Not all failures are code bugs. agent-memory-mcp classifies dead-ends into two distinct tiers:
error_loop: Code errors, compilation failures, and test breaks. Used by the 3-strike circuit breaker to prevent looping.architectural: Deliberate architectural trade-offs, discarded designs, and rejected patterns (e.g., "Do not use Redux; project uses Zustand"). Stores explicitconstraints: [...].Reopening (
reopen_dead_end): When a dependency upgrades or requirements change, an architectural dead-end can be reopened with a clear recorded rationale.
๐ฐ Token Budgeting Middleware
Large tool outputs degrade agent reasoning and exhaust context windows. agent-memory-mcp features transparent budgeting middleware:
Inspects response string size using character-to-token heuristics (~4 chars/token).
If the response exceeds the budget (default: 3,000 tokens), it trims the content at the nearest natural sentence boundary (
.,\n\n,!,?) and appends a truncation notice with instructions to bypass if necessary (full_content: true).Logs token metrics (
raw_tokens,capped_tokens,tokens_saved) directly toglobal.dbfor inspection viaget_token_metrics.
โ๏ธ Configuration
Create or modify ~/.ag-memory-mcp/config.json:
{
"max_response_tokens": 3000
}Or set the environment variable:
export AG_MEMORY_MAX_RESPONSE_TOKENS=4000๐ Quickstart
1. Claude Code
Add to your Claude Code configuration with one command:
claude mcp add agent-memory-mcp -- npx -y @getsugatension/agent-memory-mcp2. Cursor / Windsurf / Cline
Add to your mcpServers configuration (e.g. ~/.cursor/mcp.json or cline settings):
{
"mcpServers": {
"agent-memory-mcp": {
"command": "npx",
"args": ["-y", "@getsugatension/agent-memory-mcp"]
}
}
}3. Google Antigravity (Plugin Bundle)
Install the plugin into your Antigravity plugins directory (~/.gemini/config/plugins/agent-memory/):
git clone https://github.com/msking18/agent-memory-mcp.git ~/.gemini/config/plugins/agent-memoryRestart Antigravity. The plugin enables zero-turn SessionStart context hydration, scoped agent rules, and global memory tools automatically.
๐ฆ MCP Resources
memory://projects: Exposes a read-only JSON registry of all workspaces tracked byagent-memory-mcpon your machine.
๐ Recommended Agent Rule Template
Add this rule to your agent's system prompt or AGENTS.md / CLAUDE.md:
### Rule: Persistent Project Memory & Anti-Looping (v3.1)
1. Startup: When starting work on a workspace, call `check_memory_status` with the absolute project directory.
2. Bootstrap: If UNINITIALIZED, explore the codebase and save 3 foundational nodes atomically via `save_project_memory`:
- "Tech Stack & Ecosystem" (slug: "tech-stack", category: "architecture")
- "Project Structure & Architecture" (slug: "project-structure", category: "architecture")
- "Build & Run Instructions" (slug: "build-run", category: "architecture")
3. Before Editing Shared Utilities: Call `get_file_memories` with the file paths about to be edited.
4. Error Anti-Looping: Before retrying a failed test, build, or terminal command, call `check_dead_ends`. If a fix fails, record it via `record_dead_end` (specifying `kind: "error_loop"` or `"architectural"`).
5. Global Knowledge: Search machine-wide conventions and quirks with `search_global_knowledge`. Promote reusable solutions with `promote_to_global`.
6. Session Log: At the end of a major task, log changes via `save_project_memory` (category: "session", tags: ["changelog"]).๐งช Testing
Run the automated test suite across SQLite transactions, FTS5 queries, JIT migrations, token budgeting, and stdio JSON-RPC:
npm test๐ Privacy Policy
agent-memory-mcp is local-first software. All SQLite databases, search indexes, and memory stores reside exclusively on your machine (~/.ag-memory-mcp/ or your workspace directory). It collects zero telemetry and transmits no data over the network. For complete details, see PRIVACY.md.
๐ License
MIT ยฉ Manveer Singh Kahlon
Available Tools
15 toolscheck_dead_endsCheck Recorded Dead-EndsARead-onlyIdempotent
Check the anti-loop dead-end registry by error text, keyword, or file path before attempting fixes.
Inputs: project_path (required), kind, limit, query, +1 more.
check_memory_statusCheck Memory Status & Hydrate ContextBRead-onlyIdempotent
Check if project memory is initialized and retrieve core architecture index, dead-end count, and recent session timeline in one call. Auto-migrates legacy .ag-memory.json if present.
Inputs: project_path (required), timeline_limit, include_timeline.
delete_memory_nodeArchive or Delete Memory NodeADestructive
Soft-archives a memory node (default, preserves history) or permanently deletes it along with its revisions.
Inputs: id (required), hard_delete, project_path.
get_file_memoriesGet File-Anchored MemoriesBRead-onlyIdempotent
Retrieve all architectural invariants, past gotchas, and dead-ends anchored to specific workspace file or directory paths.
Inputs: file_paths (required), project_path (required), include_dead_ends.
get_session_timelineGet Session Timeline FeedARead-onlyIdempotent
Retrieve a chronological feed of past work sessions, decisions, and architectural notes for this project workspace.
Inputs: project_path (required), tag, limit, since, +1 more.
get_token_metricsGet Token Efficiency & Audit MetricsBRead-onlyIdempotent
Query machine-wide token savings, budgeting statistics, and audit logs from ~/.ag-memory-mcp/global.db.
Inputs: limit, timeframe_hours.
promote_to_globalPromote Project Memory to Global GraphB
Promote a proven project-specific memory node to the machine-wide global knowledge graph in ~/.ag-memory-mcp/global.db.
Inputs: memory_id (required), project_path (required), category, tech_stack.
read_memory_nodeRead Memory Node(s) with Staleness Detection & Global RoutingARead-onlyIdempotent
Read full markdown content of single or multiple memory nodes by id/slug (or global ID 'g-...'). Warns if referenced workspace files were modified on disk after memory was saved.
Inputs: id, ids, full_content, project_path, +1 more.
record_dead_endRecord Anti-Loop Dead-End or Architectural ConstraintA
Record a failed debugging attempt or intentional architectural constraint so future turns and sessions never repeat the same dead-end.
Inputs: root_cause (required), project_path (required), error_pattern (required), attempted_solution (required), +3 more.
reopen_dead_endReopen Dead-End RecordBIdempotent
Reopen a previously recorded dead-end when external constraints, dependencies, or requirements change.
Inputs: id (required), reason (required), project_path (required).
save_global_knowledgeSave Global Architecture Pattern or Library QuirkB
Save or update a cross-project architecture pattern or library quirk into the centralized ~/.ag-memory-mcp/global.db.
Inputs: title (required), summary (required), id, tags, +3 more.
save_project_memorySave or Batch-Upsert Project MemoryA
Save a single memory note, session log, or atomic batch of foundational architecture nodes (via entries array). Automatically updates existing nodes matching slug or id, preserving revisions in SQLite.
Inputs: project_path (required), id, slug, tags, +5 more.
search_global_knowledgeSearch Global Knowledge GraphARead-onlyIdempotent
Search machine-wide patterns, library quirks, and cross-project invariants in ~/.ag-memory-mcp/global.db using BM25 ranking.
Inputs: limit, query, category, tech_stack.
search_project_memorySearch Project Memory with FTS5 BM25 RankingBRead-onlyIdempotent
Full-text search across project titles, tags, summaries, anchored files, and active anti-loop dead-ends with contextual match snippets.
Inputs: query (required), project_path (required), limit, category.
update_memory_nodeUpdate Memory Node In-PlaceA
Update title, summary, tags, category, or files of an existing memory node. Automatically saves prior version to revisions history.
Inputs: id (required), tags, files, title, +4 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
TDQS
Scored across 15 tools
Most tools have clearly distinct purpose: project CRUD (save/read/update/delete/search), the project-specific dead-end registry, and the machine-wide global graph. The clearest overlaps are check_memory_status vs get_session_timeline (status already returns a 'recent session timeline'), check_dead_ends vs search_project_memory (which also searches active dead-ends), and read_memory_node vs get_file_memories (both surface file-anchored notes via different keys). These are workable given the descriptions but could cause misselection.
Every tool is snake_case with a leading verb (check_, get_, save_, search_, read_, update_, delete_, record_, reopen_, promote_), which is a fully predictable pattern. Scope is encoded consistently too (project vs global vs dead-end suffixes), so names alone reveal domain and action.
15 tools is within a reasonable range for a memory/knowledge server, and each has a stated job. It is slightly heavy because the surface mirrors project tools into global tools (save/search_global_knowledge, promote_to_global) and splits dead-end handling across three dedicated tools, which adds breadth not strictly required.
Core lifecycle is covered: save, read, update, soft/hard delete, search, status, timeline, plus dead-end tracking and promotion to a global graph. Gaps are minor but present: no delete or read-by-id for global knowledge (only save/search), no bulk export/import or reindex, and no explicit session-boundary tool despite session logs being a first-class concept.
Maintenance
Related MCP Connectors
Persistent, inspectable memory for AI agents with lineage, correction, and a hosted MCP endpoint.
Token-efficient MCP memory for Markdown vaults. Tiered search, GraphRAG, AI memories.
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
Persistent, portable memory for AI assistants โ your private memory graph, from any MCP client.
Related MCP Servers
- AlicenseAqualityCmaintenanceA local-first MCP server for durable agent memory using SQLite and FTS5, enabling knowledge graph storage, search, and recall for AI agents.201MIT
- AlicenseAqualityDmaintenancePersistent memory MCP server with FTS5 fuzzy search, storing data in SQLite with automatic maintenance and token-efficient TOON output.318 npm1MIT

hive-memoryofficial
FlicenseNot gradedqualityDmaintenanceMCP server for personal and shared memory with full-text search (SQLite FTS5) and outcome tracking, compatible with any MCP agent like Claude Code, Cursor, and Codex CLI.-- AlicenseNot gradedqualityDmaintenanceLocal MCP server for persistent, searchable agent memory using SQLite FTS5, replacing flat MEMORY.md files with efficient full-text search and workspace context caching.GPL 3.0