Mnemo Agent Memory
A lightweight MCP memory engine for AI coding agents that provides zero-token-waste memory recall, knowledge graph management, and Obsidian-compatible notes. It enables agents to persist and retrieve project decisions, inspect file structures efficiently, and manage a persistent knowledge graph without Python dependencies.
README
🧠 Mnemo Agent Memory
A Lightweight, High-Precision, Zero-Token-Waste Memory Engine, Knowledge Graph, and Notes System Built Exclusively for AI Coding Agents via MCP.
[!IMPORTANT] 📌 INSTALLATION & AGENT INTEGRATION:
For complete step-by-step installation guides and integration instructions for Google Antigravity, Claude Desktop, Cursor, Roo Code, and other MCP clients, please refer to INSTALL.md.
📖 Table of Contents
- The Core Problem (Why Mnemo Exists)
- Key Architectural Pillars
- System Architecture
- Core Features & Capabilities
- MCP Tools Reference
- CLI Usage & Commands
- Configuration & Environment Variables
- Project ID Auto-Locking Mechanism
- License
🎯 The Core Problem (Why Mnemo Exists)
As AI coding agents (such as Antigravity, Claude, Cursor, and Cline) work on complex codebases, they encounter three fundamental limitations:
-
Context Window Contamination & Token Waste:
Traditional agent workflows perform full-file reads (cat,read_filefrom line 1) or broad grep searches. This floods the model's context window with irrelevant lines, depletes context budgets rapidly, increases API costs by up to 600%, and causes "context drift" where the agent forgets earlier architectural decisions. -
Heavy Python Ecosystem Overhead:
Existing agent memory frameworks rely heavily on Python stacks (LangChain, ChromaDB, PyTorch, C++ bindings). In modern JavaScript/TypeScript agent environments, running Python subprocesses creates heavy memory footprints, slow startup times, and complex environment management issues. -
Volatile Project Identification:
Naïve storage fallback mechanisms identify projects dynamically based on current working directories or missing config files. When a project name changes or a config file is created midway, historical memories get orphaned in different storage namespaces.
Mnemo solves all three problems at the root. It provides a 100% pure Node.js memory engine that operates over the Model Context Protocol (MCP), enforces a strict Zero-Token-Waste Protocol, auto-locks project identity, and mirrors all memories into human-readable Markdown notes and Obsidian knowledge graphs.
⚡ Key Architectural Pillars
1. 🛡️ Zero-Token-Waste Protocol
Mnemo mandates line-range inspection (file_info) and targeted hybrid recall before any broad file reading. By fetching AST skeletons, line coordinates (startLine to endLine), and vector-relevance scores, Mnemo cuts token consumption by up to 65% while keeping precision at 100%.
2. 🔒 Auto-Lock Project ID
To eliminate storage drift, Mnemo automatically persists a mnemo.json file in the workspace root during its first normalization step. Once generated, the Project ID is permanently locked, ensuring absolute memory consistency across developer sessions, folder renames, or structural refactors.
3. 🕸️ Embedded Knowledge Graph & Decay Model
Mnemo maintains a directed persistent Knowledge Graph tracking relationships between concepts, code entities, decision logs, and file structures. It features automatic God Node detection, community clustering, and temporal node decay to archive stale context automatically.
4. 📝 Obsidian Vault Mirroring
All agent memories are saved as standard GitHub-flavored Markdown files. Mnemo includes a real-time Obsidian mirror engine (notes-export / notes-import), allowing developers to view, edit, and search their AI agent's memory bank directly inside Obsidian.
🏗️ System Architecture
flowchart TD
subgraph Client ["AI Agent / IDE Environment"]
Agent["AI Coding Agent (Antigravity / Claude / Cursor)"]
end
subgraph MCP ["Model Context Protocol Interface"]
Server["Mnemo MCP Server (stdio / HTTP)"]
end
subgraph Core ["Mnemo Engine Core (Pure Node.js)"]
Store["Index & Memory Store"]
Vec["ONNX Vector Embedding (all-MiniLM-L6-v2)"]
Graph["Knowledge Graph Engine (Nodes & Edges)"]
Lock["Project ID Auto-Lock (mnemo.json)"]
end
subgraph Storage ["Local Filesystem (~/.mnemo/projects/)"]
NotesDir["notes/ (*.md)"]
GraphDir["graph/ (graph.json)"]
VectorsDir["vectors/ (index.bin)"]
ObsidianVault["Obsidian Vault Mirror"]
end
Agent <-->|"MCP Tools (memory_recall, file_info)"| Server
Server --> Core
Core --> Storage
NotesDir <-->|"Two-way Sync"| ObsidianVault
🚀 Core Features & Capabilities
- Hybrid Vector + Keyword Search: Powered by
@xenova/transformers(runningall-MiniLM-L6-v2locally via ONNX without Python) combined with BM25-style keyword matching. - Smart Memory Auto-Injection: Automatically computes memory similarity and injects relevant context into agent prompts within a configurable token budget (default: 800 tokens).
- AST Skeleton Extraction:
file_infoparses file structures and outputs function symbols with line coordinates, preventing blind line-by-line reading. - Web Dashboard: Built-in interactive dashboard to visualize knowledge graphs, view memories, and manage project notes.
- Graph Analytics & Reporting: Generate comprehensive wiki pages, impact reports, and dependency graphs.
🔧 MCP Tools Reference
When running as an MCP Server, Mnemo exposes the following tools to the AI Agent:
| MCP Tool Name | Description |
|---|---|
memory_recall |
Performs hybrid vector + keyword search to recall relevant project decisions and context. |
memory_save |
Auto-saves new features, bug fixes, or architecture decisions into persistent memory. |
file_info |
Inspects a file's AST skeleton, line counts, imports, and symbol line ranges before reading lines. |
graph_query |
Queries entities, relationships, and neighbor nodes within the Knowledge Graph. |
graph_init |
Scans workspace and builds initial Knowledge Graph structure. |
graph_extend |
Dynamically adds new concepts, nodes, and edges to the Knowledge Graph. |
graph_analytics |
Computes graph metrics (centrality, god nodes, community clusters). |
graph_report |
Generates structured architectural reports from stored graph relationships. |
graph_wiki |
Compiles a markdown wiki from knowledge graph entities. |
graph_impact |
Analyzes potential impact of changing specific code entities or modules. |
notes_import |
Re-indexes manual Markdown notes from the local notes/ directory. |
notes_export |
Exports and mirrors all project notes to an Obsidian vault structure. |
💻 CLI Usage & Commands
Mnemo comes with a powerful CLI executable (mnemo).
# View CLI Help
mnemo --help
# Export & sync notes to Obsidian vault
mnemo notes-export
# Import & re-index notes/*.md files
mnemo notes-import
# Knowledge Graph Operations
mnemo graph init # Initialize graph for current workspace
mnemo graph --extend # Extract and extend new graph entities
mnemo graph query <name> # Search specific entity relations
mnemo graph prune # Clean up stale/archived graph nodes
⚙️ Configuration & Environment Variables
Mnemo can be configured globally via ~/.mnemo/config.json or overriden per-session using Environment Variables (MNEMO_*):
| Environment Variable | Default | Description |
|---|---|---|
MNEMO_DATA_DIR |
~/.mnemo |
Root storage folder for notes, vectors, graphs, and models. |
MNEMO_PROJECT_ID |
(auto-detect) | Explicit override for Project ID (bypasses auto-detection). |
MNEMO_PORT |
3112 |
HTTP Server & Web Dashboard port. |
MNEMO_AUTO_INJECT |
true |
Enables/disables automatic memory injection into agent prompts. |
MNEMO_AUTO_INJECT_BUDGET |
800 |
Maximum token budget for injected memory context. |
MNEMO_INJECT_THRESHOLD |
0.35 |
Minimum cosine similarity score required for context injection. |
MNEMO_RULES_LEVEL |
normal |
Rule aggressiveness level (strict | normal | light). |
MNEMO_GRAPH_AUTO |
true |
Automatically triggers graph_extend upon memory_save. |
MNEMO_GRAPH_EXTEND_THRESHOLD |
0.5 |
Minimum confidence threshold for new graph node/edge creation. |
🔒 Project ID Auto-Locking Mechanism
To guarantee 100% session consistency, Mnemo uses a 3-tier deterministic resolution strategy:
mnemo.json(Priority 1): ReadsnameorprojectIdfrom workspace root.package.json(Priority 2): Readsnameifmnemo.jsondoes not exist yet.- Folder Slug Fallback (Priority 3): Uses the last two path segments of the workspace folder.
The Auto-Lock Feature: Upon first run, if mnemo.json is missing, Mnemo calculates the target ID and immediately writes a locked mnemo.json file into the root folder. This prevents Project ID shifts even if package.json is added later or the folder is relocated.
📄 License
Distributed under the MIT License. See LICENSE for details.
<p align="center"> <b>Built for high-efficiency AI Pair Programming.</b><br> <i>Read <a href="INSTALL.md">INSTALL.md</a> to set up Mnemo with your AI Agent today.</i> </p>
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。