Memento Protocol
Persistent memory for AI agents — store what matters, recall by meaning, skip the rest
The Memento Protocol
Persistent memory for AI agents.
AI agents have anterograde amnesia — every session starts blank. The Memento Protocol gives agents a structured way to remember, not by recording everything, but by writing instructions to their future selves. Memories decay, consolidate, and evolve — like biological memory, not a log file.
Quick Start
npx memento-mcp init
This creates .memento.json, detects your agent (Claude Code, Codex, Gemini CLI, OpenCode), writes the correct MCP config, and registers hooks — all in one command.
Manual Setup
git clone https://github.com/myrakrusemark/memento-protocol.git
cd memento-protocol && npm install
Verify the install:
npm run test:smoke
You should see all tools listed and "All smoke tests passed."
Step 1: Sign up
curl -X POST https://memento-api.myrakrusemark.workers.dev/v1/auth/signup \
-H "Content-Type: application/json" \
-d '{"workspace": "my-project"}'
No email, no password, no OAuth. One curl, one key. Optionally include "email" for account recovery later.
Save the api_key from the response — you'll need it next.
Step 2: Configure your MCP client
Claude Code — .mcp.json in your project root (or ~/.claude.json globally):
{
"mcpServers": {
"memento": {
"command": "npx",
"args": ["-y", "memento-mcp"]
}
}
}
OpenAI Codex — .codex/config.toml:
[mcp_servers.memento]
command = "npx"
args = ["-y", "memento-mcp"]
Gemini CLI — .gemini/settings.json:
{
"mcpServers": {
"memento": {
"command": "npx",
"args": ["-y", "memento-mcp"]
}
}
}
OpenCode — opencode.json:
{
"mcp": {
"memento": {
"type": "local",
"command": ["npx", "-y", "memento-mcp"],
"enabled": true
}
}
}
Set credentials via .memento.json (created by npx memento-mcp init) or environment variables MEMENTO_API_KEY, MEMENTO_API_URL, MEMENTO_WORKSPACE.
Step 3: Restart your client
The MCP server connects at startup. Restart so it picks up the new config.
Step 4: First session
> memento_health() # verify connection
> memento_store( # store your first memory
content: "API uses /v2 endpoints. Auth is Bearer token in header.",
type: "instruction",
tags: ["api", "auth"]
)
> memento_recall(query: "api auth") # find it again
That's it. The agent reads memory at session start, updates it as it works, and writes instructions for next time.
Add to Your CLAUDE.md
Paste this block into your project's CLAUDE.md to teach your agent memory discipline:
## Memory (Memento Protocol)
On session start:
1. `memento_health` — verify connection
2. `memento_item_list` — check active work items and their next actions
3. `memento_recall` with current task context — find relevant past memories
During work — actively manage your own memories:
- `memento_store` when you learn something, make a decision, or discover a pattern
- `memento_recall` before starting any subtask — someone may have already figured it out
- `memento_item_update` as you make progress — don't wait until the end
- `memento_item_create` when new work emerges
- `memento_skip_add` the moment you hit a dead end (with expiry)
- `memento_consolidate` when recall returns 3+ overlapping memories on the same topic
- Delete or archive items that are done or wrong — stale memory is worse than no memory
Writing discipline:
- Instructions, not logs: "API moved to /v2 — update all calls" not "checked API, got 404"
- Tag generously — tags power recall and consolidation
- Set expiration on time-sensitive facts
- The test: could a future you, with zero context, read this and know exactly what to do?
Your memories are yours. Create, update, and delete them whenever the work demands it —
not just at session boundaries.
The Protocol
Installing Memento gives your agent memory. The Protocol is the system you build around it — orientation after context loss, automatic recall, writing discipline, distillation before context resets, identity that persists across sessions.
Full guide: The Protocol on hifathom.com.
Hooks
Hooks automate memory at session boundaries — recall on every message, distillation before context loss, identity injection at session start. Five production-ready scripts are included in scripts/:
| Script | What it does |
|---|---|
memento-sessionstart-identity.sh | Injects identity crystal + version check at session start |
memento-userprompt-recall.sh | Recalls memories relevant to the user's message |
memento-stop-recall.sh | Recalls memories from the assistant's own output (autonomous work) |
memento-precompact-distill.sh | Extracts memories from the conversation before context compression |
memento-codex-notify.sh | Stores post-turn summaries from Codex CLI as memory observations |
Agent hook support
npx memento-mcp init auto-detects your agent and registers the appropriate hooks. Not all agents support the same hook events — here's what gets wired up:
| Hook | Claude Code | Gemini CLI | Codex CLI |
|---|---|---|---|
| Session start / identity | SessionStart | SessionStart | — |
| Recall on user message | UserPromptSubmit | BeforeAgent | — |
| Recall on assistant output | Stop | SessionEnd | — |
| Pre-compaction distillation | PreCompact | PreCompress | — |
| Post-turn memory storage | — | — | notify |
OpenCode uses a TypeScript plugin system — MCP tools work, but hooks require a different integration pattern.
See scripts/README.md for setup, configuration, and how to write your own hooks.
Dashboard
Browse and manage memories visually at hifathom.com/memento/dashboard. Paste your API key and workspace name to connect.
Documentation
Full reference docs at hifathom.com/memento:
- Quick Start — 5-minute setup guide
- The Protocol — orientation, recall hooks, writing discipline, distillation, identity
- Core Concepts — memories, working memory, skip lists, identity crystals
- MCP Tools — full tool reference with parameters and examples
- API Reference — REST endpoints, request/response schemas, authentication
- Self-Hosting — deploy your own instance with Cloudflare Workers + Turso
Development
npm test # Run unit + integration tests
npm run lint # Lint with ESLint
npm run format:check # Check formatting with Prettier
npm run test:smoke # Quick smoke test of all tools
License
MIT
เซิร์ฟเวอร์ที่เกี่ยวข้อง
Rework
Integrate AI applications with the Rework platform to manage projects, tasks, workflows, and jobs.
Retrieval Augmented Thinking
A server implementing Chain of Draft reasoning for enhanced problem-solving capabilities using OpenAI.
legends-mcp
Chat with legendary founders & investors via MCP. 36 AI personas including Elon Musk, Warren Buffett, Steve Jobs, CZ, and more. No API key required - Claude does the roleplay!
Joplin MCP Server
A server that enables access to Joplin notes and to-dos through the Model Context Protocol (MCP).
UNO: Unified Narrative Operator
A text enhancement tool that transforms story content into rich, detailed narratives using advanced literary techniques and heuristic analysis.
MCP Conductor
An advanced MCP server for intelligent conversation context management and session continuity, requiring the Claude Desktop application and a Node.js environment.
CData Zoho Projects Server
A read-only MCP server to query live Zoho Projects data using the CData JDBC driver.
Tomba MCP
Tomba, your unique B2B email finder and verifier, provides a distinctive lead database for effortless and effective outreach scaling.
WordPress MCP Server
A secure bridge between AI assistants and WordPress, enabling site management and content operations through natural language.
FullScope-MCP
An MCP server for content summarization, supporting web scraping, file reading, and direct model calls.