agent-memory-mcp
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.
agent-memory-mcp
agent-memory-mcp is a local MCP server that gives agents shared, durable memory backed by SQLite.
Use it when you want Codex, Claude Code, Xcode Coding Assistant, or other MCP clients to stop starting from zero on every turn. Instead of each client keeping its own hidden history, they all read and write to the same local memory layer.
Default data path: $HOME/.agent-memory/memory.db
If you want multiple clients to share the same memory, point them at the same AGENT_MEMORY_HOME.
Why This Exists
Most agent workflows have the same failure mode:
a new chat or new client loses important project context
stable preferences and repo conventions have to be repeated
imported sessions stay trapped inside one tool's transcript format
one agent cannot easily benefit from what another agent already learned
agent-memory-mcp fixes that by adding a local memory layer with:
shared storage across clients
scope-aware retrieval for
global,project, andsessionmemorydurable fact storage with dedupe, redaction, and optional TTL
importers for Codex, Claude, and ChatGPT history
optional embeddings for better ranking, with lexical-only fallback when embeddings are unavailable
Related MCP server: context-ledger
Who Should Use It
You should use this repo if:
you work in the same repo across multiple agents or chat sessions
you want agents to remember stable project facts, decisions, and preferences
you want a local memory system you control instead of a hosted service
you want imported session history to become searchable memory, not dead logs
You probably do not need it if:
you only use one short-lived chat and do not care about durable context
you want team-wide cloud sync across machines; this project is local-first
What The Agent Actually Does With It
This server is most useful when the client uses it on every turn.
Recommended turn loop:
Before responding, call
memory_get_contextwith the latest user message plusproject_pathand optionallysession_id.Use the returned context bundle while reasoning.
After responding, call
memory_captureto extract facts from the turn.For durable rules or preferences, also call
memory_upsert.
That turns memory from "maybe useful storage" into a real operating layer for the agent.
Core Tools
Tool | Use it for |
| Default turn-prep retrieval. Returns a scope-aware, token-budgeted context bundle. |
| Explicit lookup when the agent needs to search memory on purpose. |
| Fallback for payload-constrained environments. Not the normal default for Codex or Claude Code. |
| Extract salient facts from raw conversation text and store them as memories. |
| Save or update durable facts, preferences, or conventions directly. |
| Soft-delete a specific memory entry. |
| Bulk soft-delete memories in a scope. |
| Check DB state, embeddings health, and retrieval mode. |
How Memory Is Scoped
global: user-wide facts that should apply everywhereproject: repository-specific facts, conventions, and decisionssession: temporary context for one thread or run
This matters because the same fact can be appropriate at one scope and wrong at another. For example, a coding-style preference may be global, while a release convention belongs at project scope.
Quick Start
Requirements
Node.js
>=22optional: Ollama if you want semantic embeddings
1. Install
git clone https://github.com/mikeylong/agent-memory-mcp.git
cd agent-memory-mcp
npm install
npm run buildThis project is currently distributed from source/GitHub. npm publishing is intentionally out of scope.
2. Configure clients
For Codex and Xcode Coding Assistant, use the installer:
scripts/install-clients.shUseful flags:
scripts/install-clients.sh --dry-run
scripts/install-clients.sh --codex
scripts/install-clients.sh --xcode
scripts/install-clients.sh --automations-mode create
scripts/install-clients.sh --agent-memory-home "$HOME/.agent-memory"
scripts/install-clients.sh --forceWhat the installer does:
updates
~/.codex/config.tomlupdates
~/Library/Developer/Xcode/CodingAssistant/codex/config.tomlwhen that directory already existscan create the recommended Codex automations under
~/.codex/automationscreates backups before editing existing config files
writes changes atomically
For Claude Code, enable the hook-based integration:
npm run enable:claude-wrapper
source ~/.zshrcAfter that, normal claude usage keeps the native interactive UX while memory read/write runs through Claude hooks on every turn.
Claude Code permissions tip:
{
"permissions": {
"allow": ["mcp__agent-memory"]
}
}3. Sanity check
Restart any clients that were already open, then call memory_health.
Healthy first-run shape:
{
"ok": true,
"db": "ok",
"embeddings": "ok",
"version": "0.3.0 (schema 4)",
"retrieval_mode": "semantic+lexical",
"embeddings_provider": "ollama",
"embeddings_reason": "healthy",
"actions": []
}If Ollama is not running, the server still works in lexical-only mode.
First Practical Workflow
Once the server is installed, the high-value workflow is:
Point every client at the same
AGENT_MEMORY_HOME.Make sure the client actually calls
memory_get_contextbefore answering.Make sure it calls
memory_captureafter answering.Use
memory_upsertfor stable facts that must survive noise and transcript churn.Import past sessions so old work becomes searchable memory.
If you skip step 2 and step 3, you have storage but not a memory loop.
Start Commands And Shortcuts
Task | Command |
Start the MCP server directly |
|
Start Codex with enforced memory wrapper |
|
Enable Claude hook integration |
|
Legacy Claude wrapper path |
|
Show recommended Codex automations |
|
session_id is optional for wrapper flows. If omitted, one is auto-generated.
Import Existing History
You do not need to start with an empty memory store.
Import the latest local sessions:
scripts/import-codex-session.sh --project-path "$HOME/projects/agent-memory"
scripts/import-claude-session.sh --project-path "$HOME/projects/agent-memory"Import specific files:
scripts/import-codex-session.sh \
--session-file "$HOME/.codex/sessions/YYYY/MM/DD/rollout-<id>.jsonl" \
--project-path "$HOME/projects/agent-memory"
scripts/import-claude-session.sh \
--session-file "$HOME/.claude/projects/<workspace-slug>/<session-id>.jsonl" \
--project-path "$HOME/projects/agent-memory"Import a ChatGPT export:
node dist/importChatgptExport.js \
--export-zip "$HOME/Downloads/ChatGPT Data Download.zip" \
--capture-scope global \
--branch-strategy active \
--coverage all \
--max-facts 5Importer flags for Codex and Claude session scripts:
--session-file <path>optional override--project-path <path>defaultpwd--scope <project|global|session>defaultproject--session-id <id>only when--scope session--max-facts <n>default25--skip-tool-assisteddefault; stores transcript provenance but skips extracted facts when non-memory tools or web search were used--no-skip-tool-assistedopt out and capture facts even from tool-assisted sessions
Set AGENT_MEMORY_SKIP_TOOL_ASSISTED=0 to make the opt-out the default for importer, import-sync, wrapper, and hook flows.
Retrieval Behavior
memory_get_context is the default retrieval path for normal turn preparation.
memory_search is the default explicit lookup tool. When called without explicit scopes, it searches the current context by default:
globalproject_path, when providedsession_id, when provided
Generic retrieval de-prioritizes noisy captured/import transcript memories and backfills them only when cleaner matches are insufficient.
Client behavior:
Client |
|
Codex / Claude Code | Preferred explicit lookup path with rich defaults |
Unknown clients | Adaptive retry with compact-safe fallback if needed |
memory_search_compact remains available for constrained environments or explicit compact-mode use. It is not the normal default for Codex or Claude Code.
Optional Embeddings
Embeddings improve ranking but are optional.
default provider: Ollama
default model:
nomic-embed-textdefault Ollama URL:
http://127.0.0.1:11434
If Ollama is unavailable:
the server still works
retrieval falls back to lexical-only mode
memory_healthreports a degraded embeddings state with suggested actions
If you want to disable embeddings on purpose:
AGENT_MEMORY_DISABLE_EMBEDDINGS=1 node dist/index.jsRecommended Automations
Use the bootstrap command to print the recommended Codex automation set for a workspace:
npm run -s automation:bootstrap -- --project-path "$HOME/projects/agent-memory"To let the installer create or update the recommended automations:
scripts/install-clients.sh --codex --automations-mode create --project-path "$HOME/projects/agent-memory"The bootstrap output is the onboarding source of truth for:
automation name
schedule
prompt
runtime settings such as model, reasoning effort, and execution environment when specified
workspace cwd
whether each automation already exists under
~/.codex/automations
Recommended automation checks:
Memory Durability Audit: audit-only weekly memory-quality pass. It runs the deterministic durability-audit CLI, classifies recent memories and ChatGPT-export synthesis rows, preserves transcripts and provenance rows, and does not mutate memory or create inbox/email side effects.Memory cleanup: scheduled cleanup runs dry-run only and reports candidate counts/samples. Apply cleanup manually after review.
Included automation-oriented CLIs:
npm run -s automation:health-driftnpm run -s automation:import-sync -- --project-path <path> [--max-session-bytes <n>] [--max-claude-session-bytes <n>] [--max-messages <n>] [--source-timeout-ms <n>]npm run -s automation:durability-audit -- [--recent-hours <n>] [--recent-limit <n>] [--synthesis-limit <n>]npm run -s automation:retrieval-qanpm run -s automation:cleanup -- --dry-run|--apply [--before <iso>]npm run -s automation:cleanup -- --apply --expired-only --expired-grace-days 0
Maintenance CLIs:
npm run -s maintenance:backfill-embeddings -- --dry-runnpm run -s maintenance:backfill-embeddings -- --apply [--limit <n>] [--batch-size <n>] [--max-content-bytes <n>] [--embedding-input-bytes <n>]npm run -s maintenance:chunk-transcripts -- --dry-runnpm run -s maintenance:chunk-transcripts -- --apply [--limit <n>] [--batch-size <n>] [--min-content-bytes <n>] [--chunk-bytes <n>] [--overlap-bytes <n>]
Use npm run test:retrieval for the fixture-driven retrieval regression suite that CI runs on every push and pull request.
npm run -s automation:retrieval-qa remains a narrower runtime smoke check that writes and cleans a temporary session in an isolated temporary database. Use npm run -s automation:retrieval-qa -- --configured-runtime when you specifically want to check the configured AGENT_MEMORY_DB_PATH.
Manual MCP Configuration
If you do not want the installer to edit config files, add the MCP server entry manually.
[mcp_servers.agent-memory]
command = "/absolute/path/to/node"
args = ["/absolute/path/to/agent-memory-mcp/dist/index.js"]
enabled = true
[mcp_servers.agent-memory.env]
AGENT_MEMORY_HOME = "/absolute/path/to/.agent-memory"Codex config path:
~/.codex/config.toml
Xcode config path:
~/Library/Developer/Xcode/CodingAssistant/codex/config.toml
GUI-launched apps often need an absolute Node path instead of plain node.
Advanced Commands
Raw wrapper commands:
node dist/wrapper.js --codex --project-path "$HOME/projects/agent-memory" --session-id my-session
node dist/wrapper.js --claude --project-path "$HOME/projects/agent-memory" --session-id my-sessionImporter binaries:
agent-memory-import-codex --session-file "$HOME/.codex/sessions/YYYY/MM/DD/rollout-<id>.jsonl"
agent-memory-import-claude --session-file "$HOME/.claude/projects/<workspace-slug>/<session-id>.jsonl"Optional client-class override:
AGENT_MEMORY_CLIENT_CLASS_OVERRIDE=constrained node dist/index.jsAllowed values: auto, rich, constrained, unknown
Limitations
local-first storage; no built-in multi-machine sync
stdio transport in v1
redaction is heuristic, not a full DLP system
embeddings are optional and depend on local Ollama availability
Contributing
npm run privacy:scan
npm run build
npm run test:retrieval
npm testLicense
MIT
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-by-default, local-first memory/context/task orchestrator for MCP apps and agents.
Hosted agent memory: store, search, and recall facts across sessions from any MCP client.
Cross-tool persistent memory and context for AI assistants over MCP.
Hosted memory for AI agents over MCP. One memory shared by all your agents.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceProvides AI agents with persistent, local, and shareable project memory by storing decisions and code context in a searchable SQLite index, supporting keyword and semantic search via MCP.3MIT
- AlicenseBqualityDmaintenanceProvides local, explicitly scoped memory for coding agents via MCP, storing durable project knowledge in a per-repository SQLite database with tools to record, search, and retrieve context.5MIT
- AlicenseNot gradedqualityBmaintenanceEnables concurrent MCP clients to share a persistent SQLite-backed key-value memory store with semantic search, write attribution, and audit history.MIT
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients to persist project-scoped memories in a local SQLite database and later search, recall, list, export, or delete them across sessions through stdio tools.MIT