Memento
Memento is a local-first, open-source MCP middleware that gives AI agents persistent memory, proactive goal enforcement, and autonomous intelligence using a SQLite temporal graph with Reciprocal Rank Fusion retrieval.
README
<div align="center"> <img src="assets/memento-logo.svg" alt="Memento Logo" width="100%">
<h1>Memento</h1> <p><strong>The Autonomous Nervous System for AI Agents</strong></p>
Memento is a local-first, open-source MCP middleware that gives your AI agents (Cursor, Claude Desktop, Trae, etc.) persistent memory, proactive goal enforcement, and autonomous intelligence — all running on a zero-cost SQLite temporal graph with Reciprocal Rank Fusion (RRF) retrieval.
No cloud databases. No API calls for storage. Everything stays on your machine.
Architecture
Temporal Graph Memory (RRF)
Built on SQLite FTS5 (full-text search) and cosine similarity (vector embeddings). Fuses keyword matches and semantic meaning via Reciprocal Rank Fusion. WAL-mode enabled for concurrency.
Tri-State Goal Enforcer
Keep your AI aligned with project objectives at three escalation levels:
- Level 1 — Context Injection: Automatically injects active goals into every search result. Active by default.
- Level 2 — Strict Mentor: Forces the AI to submit code/plans for goal alignment evaluation via LLM.
- Level 3 — Daemon Push: File-watcher monitors your workspace and proactively flags goal drift.
Active Coercion (Code Immune System)
Deterministic regex/tree-sitter rules that block anti-patterns at commit time and in the IDE. 100% deterministic — zero LLM hallucination risk during enforcement.
Autonomous Agent
Background cognitive loop with four levels:
- off: No background behavior (default).
- passive: Observe health and patterns every 5 min. No modifications.
- active: Consolidate memories, extract KG, warm caches, detect anomalies every 2 min.
- autonomous: All of the above plus dream synthesis, goal drift detection, task generation, health reports every 1 min.
Workspace Isolation
Each project gets its own .memento/ directory with an isolated SQLite database. No context bleeding between projects. Configure via MEMENTO_DIR or per-project .cursor/mcp.json.
Session Continuity
- Auto-checkpoints every 25 tool calls with full L1 working memory snapshot.
- Auto-resume restores goals and context from the previous session.
- LLM-agnostic handoff prompts for session transfer between agents.
Project Memory Graph
Semantic entity-relationship graph on top of the Knowledge Graph. Track files, components, decisions, and their dependencies. Impact analysis shows what breaks when you change something.
Unified Tool API (v0.3.x)
Memento exposes 14 action-based tools via MCP. Each tool uses an action parameter instead of separate tools per operation:
| Tool | Actions | Purpose |
|---|---|---|
memento |
(main router) | Primary proactive memory interface |
memento_project |
set_state, get_state, delete_state, set_goals, list_goals, summary |
Vision, milestones, blockers, goals |
memento_session |
begin, resume, handoff, status, list |
Session lifecycle and handoff |
memento_graph |
add_entity, add_relation, query, impact, summary |
Project Memory Graph |
memento_search |
basic, advanced, explain |
FTS, vNext pipeline, routing trace |
memento_remember |
add, consolidate, share, evaluate, hit |
Memory write operations |
memento_configure |
enforcement, coercion, daemon, autonomy, consolidation_scheduler, kg_scheduler, dependency_tracker, superpowers, access |
All configuration |
memento_cognitive |
dream, align, warnings, tasks |
Cognitive engine operations |
memento_health |
status, health, memory, kg, quality, relevance, cache, explain |
Diagnostics |
memento_coercion |
list_presets, apply_preset, list_rules, add_rule, remove_rule, install_hooks |
Active Coercion management |
memento_kg |
extract, health, cross_workspace_stats |
Knowledge Graph operations |
memento_notifications |
configure, list, dismiss |
Proactive notifications |
memento_audit_dependencies |
(standalone) | Dependency audit |
memento_migrate_workspace_memories |
(standalone) | Workspace memory migration |
Quick Start
Install
pip install memento-mcp
Or run without installing:
uvx memento-mcp
Configure (Cursor / Claude Desktop / Trae)
Add to your global mcp.json (e.g. ~/.cursor/mcp.json):
{
"mcpServers": {
"memento": {
"command": "memento-mcp",
"env": {
"OPENAI_API_KEY": "your-api-key",
"OPENAI_BASE_URL": "https://api.openai.com/v1",
"MEM0_MODEL": "openai/gpt-4o-mini"
}
}
}
}
For per-project workspace isolation, add to .cursor/mcp.json in your project root:
{
"mcpServers": {
"memento": {
"command": "memento-mcp",
"env": {
"OPENAI_API_KEY": "your-api-key",
"OPENAI_BASE_URL": "https://api.openai.com/v1",
"MEM0_MODEL": "openai/gpt-4o-mini",
"MEMENTO_DIR": "${workspaceFolder}"
}
}
}
}
Add .cursor/ to your .gitignore to avoid committing API keys.
Verify
memento-mcp --help
memento --help
<details> <summary>Running without OpenAI (offline / testing)</summary>
Set MEMENTO_EMBEDDING_BACKEND=none to disable embeddings. Memento falls back to FTS5-only search — no API key needed.
MEMENTO_EMBEDDING_BACKEND=none memento-mcp
</details>
Environment Variables
| Variable | Description |
|---|---|
OPENAI_API_KEY |
Required for embeddings and cognitive features |
OPENAI_BASE_URL |
Optional OpenAI-compatible endpoint (e.g. OpenRouter) |
MEM0_MODEL |
LLM model for cognitive features |
MEM0_EMBEDDING_MODEL |
Embeddings model for hybrid search |
MEMENTO_EMBEDDING_BACKEND |
Set to none for FTS5-only (no API key) |
MEMENTO_DIR |
Workspace root for .memento/ state |
MEMENTO_UI |
Enable local web UI (1/true) |
MEMENTO_UI_PORT |
Local UI port (default 8089) |
MEMENTO_HANDOFF_AUTO_CHECKPOINT_EVERY_N_EVENTS |
Auto-checkpoint frequency (default 25) |
CLI Usage
Memento works from the terminal too:
# Auto-capture git context as a memory
memento capture --auto
# Save a free-form note
memento capture --text "Resolved auth timeout by increasing JWT expiry"
# Search memories
memento search "how did I fix the promise bug"
# Show workspace status
memento status
How Proactivity Works
Memento operates at two levels:
Always-on (zero configuration)
- Goal awareness: Every tool call is checked against active goals. If work drifts, a warning is appended.
- Auto-resume: L1 working memory (goals, context) restores from the previous session's checkpoint.
- Auto-checkpoint: Every 25 events, a full session snapshot is saved with project state and handoff prompt.
- Session diff: Each checkpoint computes the delta from the previous session (goals changed, files touched).
Activatable (via memento_configure)
- L2 enforcement: Goal alignment checks via LLM on explicit request.
- L3 daemon: File-watcher with proactive goal drift notifications.
- Autonomous agent: Background consolidation, KG extraction, dream synthesis, task generation.
- Active coercion: Deterministic code pattern enforcement.
- Consolidation/KG schedulers: Background deduplication and knowledge extraction.
Example activation sequence:
memento_project(action="set_goals", goals=["Implement auth flow", "Refactor DB layer"])
memento_configure(action="enforcement", level="level2", enabled=true)
memento_configure(action="consolidation_scheduler", enabled=true, interval_minutes=30)
memento_configure(action="autonomy", level="active")
License
Memento is released under the GNU Affero General Public License v3.0 (AGPL-3.0). If you modify Memento and offer it as a network service, you must release your modified source code under the same license.
See LICENSE for details.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。