A community-driven registry for Claude, Cursor, Windsurf, Cline & more. Not affiliated with Anthropic.
Are you the author? Sign in to claim
Local-first Model Context Protocol (MCP) memory layer for Codex CLI/Desktop, Claude Code, Gemini CLI, Qwen/DeepSeek/Olla
Other languages: Español | Deutsch | Português do Brasil | 中文 | 日本語
Portable, auditable, local-first MCP memory for MCP-compatible AI agents and coding workflows.
codex-agent-mem keeps durable project memory outside the model runtime, compresses continuity into smaller working packs, and carries forward operational state so MCP-compatible AI agents can resume with less repetition, fewer false “done” claims, and more control over what stays in context.
Everything is stored and processed locally by this MCP: SQLite database, FTS index, snapshots, telemetry metadata, and the optional inspector UI. codex-agent-mem does not send your memory, project data, prompts, or telemetry to any external server. MCP clients may still expose tool results to the model or service you configure, so treat retrieved memory as local tool output handed to that client.
Born for Codex and GPT workflows, codex-agent-mem has grown into a portable MCP memory layer for MCP-compatible runtimes including Codex CLI/Desktop, Claude Code, Google Gemini CLI, Qwen Code workflows using Ollama models, and other local or third-party CLI agent stacks. Validation is tracked per client/runtime and evidence level. Model-specific details stay in the validation docs so the README can describe the public surface without overclaiming one runtime.
codex-agent-mem lives locally, keeps memory auditable and pull-based, and does not send your stored memory to any external service.
Public baseline. Built in small, testable slices and still evolving, but already aligned for real use.
v1.0.2 fixes a project identity edge case where generated codex-agent-mem context inside AGENTS.md could be mistaken for active project scope by MCP hosts or agent clients. It also lets manual notes initialize a missing local project record and preserves existing project root metadata on conflicting updates.
v1.0.1 fixes one local daemon/stdio bridge idle-timeout path that could surface as a false Transport closed incident when --daemon-url is used.
v1.0.1 serializes shared request handling inside the optional threaded local daemon so one SQLite-backed server instance is not driven concurrently.
v1.0.1 hardens the public local-first daemon surface: loopback-only bind validation, optional bearer-token auth for /mcp, sanitized /health, and token forwarding from the stdio bridge.
v1.0.1 adds a generated-context instruction-hierarchy guardrail: retrieved memory is advisory project context, not a higher-priority instruction; this is a basic guardrail, not prompt-injection proof.
v1.0.1 documents that local SQLite memory is plaintext by default in the public 1.0.x line and must not be treated as a secrets vault.
v1.0.1 normalizes list-returning MCP tool payloads so structuredContent uses object roots like {items, count} instead of root arrays for stricter clients such as Claude Code.
v1.0.1 adds session-aware retrieval for persisted memory: mem_session_list lists recent sessions, mem_scope_resolve ranks persisted lanes from explicit thread/path hints, mem_bootstrap_context avoids project-wide startup packs for ambiguous containers, and optional session_id filters retrieval tools so broad project scopes do not mix chats or agents. Project-wide packs that span multiple sessions or inferred sub-scopes emit a visible scope warning and recommend narrowing first. This is not live current-turn awareness.
v1.0.1 keeps normal continuity installs writable by default; --read-only is an explicit retrieval-only audit/debug mode, not the default operating mode.
low-impact MCP runtime profiles: minimal, standard, and full
explicit --read-only audit/debug mode that blocks mutating tools and avoids closure writes
lazy SQLite initialization so unused MCP connections stay cheap
compact MCP responses by default, with full payloads kept in structuredContent
known_pack_hash / not_modified support so unchanged continuity packs are not resent
runtime heartbeat diagnostics, spawn-storm warning, optional telemetry, and an optional daemon/stdio bridge
Latest releases: v1.0.2 Identity + Scope Patch | v1.0.1 Transport + Local Security Hotfix | v1.0.0 Low-Impact Runtime
| Scenario | Profile | Source tokens | Pack tokens | Saved | not_modified | Tools | Lazy init | Read-only |
|---|---|---|---|---|---|---|---|---|
| Small project continuity | minimal | 1,841 | 253 | 86.26% | true | 4 | false->true | true |
| Medium agent workflow | minimal | 4,855 | 270 | 94.44% | true | 4 | false->true | true |
| Large repeated audit | minimal | 9,731 | 269 | 97.24% | true | 4 | false->true | true |
| Sub-agent handoff example | minimal | 6,523 | 276 | 95.77% | true | 4 | false->true | true |
Across these reproducible fixtures, repeated operational context was reduced from ~22,950 source tokens to ~1,068 memory-pack tokens, an approximate 95.35% reduction. This is not a universal guarantee; it shows the effect when an agent would otherwise resend the same project continuity.
Tools=4 refers to the pre-session-aware minimal profile used by these fixtures. In v1.0.1, minimal also includes mem_session_list, mem_scope_resolve, and mem_bootstrap_context, and the standard profile exposes 20 tools for broader retrieval, governance, and audit workflows.
| Runtime | Setup | Observed metrics | Result |
|---|---|---|---|
| Writable MCP default | Codex/Gemini/Claude local daemon bridges, read_only=false; full where writable tools are required | mem_note_create wrote indexed manual notes and mem_search / mem_context_pack recovered them; mem_snapshot_create(project_key, label, session_id) recorded high-confidence provenance | Writable manual-note and snapshot-provenance smokes passed |
| Codex Desktop | Codex Desktop, MCP stdio, explicit retrieval-only minimal, read-only, compact synthetic v1.0 fixtures | ~22,950 source tokens -> ~1,068 pack tokens, ~95.35% repeated-context reduction, not_modified=true on repeated packs | Retrieval-only MCP validation plus public reproducible verification; writable continuity is covered by the writable default row |
Codex CLI / codex exec | Codex CLI MCP stdio path, short-lived / ephemeral execution | same local MCP server and config style as Desktop; short-lived CLI lifecycle validated separately from the long-lived Desktop host behavior | Validated Codex CLI path |
| Google Gemini CLI | codex-agent-mem MCP stdio, explicit retrieval-only standard, read-only; compact when structured payloads are visible, otherwise verbose | stable process, request counter increased as expected, object-root payloads verified where visible | Retrieval-only MCP validation with client-exposure caveat |
| Claude Code | Claude Opus 4.7, codex-agent-mem MCP stdio only, explicit retrieval-only standard, read-only, compact | requests 3 -> 8, lazy init false -> true, same_db_process_count=2 with one Claude Code host active, spawn_storm_warning=false, mem_search count=2 | Retrieval-only MCP validation passed |
| Qwen Code | Qwen Code 0.15.0, local Ollama, qwen3.6:latest, explicit retrieval-only standard, read-only, compact | real MCP calls to mem_context_pack, mem_search, mem_open_work, mem_completion_check, mem_health_runtime; requests 8, lazy init true, spawn_storm_warning=false, not_modified=true | Retrieval-only local MCP validation passed |
| Qwen local model smokes | Qwen Code 0.15.0 with Ollama models qwen3.6:35b-a3b-q8_0 and qwen3.5:9b | both models answered CLI smoke tests and invoked mem_health_runtime through MCP stdio; retrieval-only read_only=true, clean stdin_eof exits | Retrieval-only local model smokes passed |
| DeepSeek-V3.2 | Qwen Code 0.15.0, deepseek-v3.2:cloud through Ollama Cloud, explicit retrieval-only standard, read-only, compact | real MCP calls to mem_context_pack, mem_search, mem_health_runtime; requests 6, spawn_storm_warning=false, not_modified=true | Retrieval-only cloud-backed MCP validation passed |
| Minimax M2.5 | Qwen Code 0.15.0, minimax-m2.5:cloud through Ollama Cloud, explicit retrieval-only standard, read-only, compact | real MCP calls to mem_context_pack, mem_search, mem_health_runtime; requests 6, not_modified=true | Retrieval-only cloud-backed MCP validation passed |
| Kimi Code CLI | Kimi Code CLI 1.38.0, codex-agent-mem MCP stdio, explicit retrieval-only standard, read-only, compact | kimi mcp test codex-agent-mem connected and listed the expected standard-profile tools; Kimi K2.5 / Kimi K2.6 full model tool-call validation remains in continuous evaluation | Retrieval-only MCP connection validated; model-run validation not claimed |
| Grok / xAI | Protocol-level compatibility note | MCP stdio / JSON-RPC protocol behavior reviewed | Protocol note |
Grok / xAI is listed as a protocol-level compatibility note, not live model tool-call validation. The live validated rows are the MCP client/model pairs measured directly: Codex Desktop/CLI, Google Gemini CLI, Claude Code, Qwen Code, Qwen local model smokes, DeepSeek-V3.2 through Ollama Cloud, Minimax M2.5 through Ollama Cloud, and Kimi Code CLI connection validation. More generally, codex-agent-mem is model-agnostic at the MCP layer; new pairs are added as their live measurements are captured.
codex-agent-mem includes a reproducible verification sandbox and a public evidence export for v1.0.0. The fixture approach is intentional: the MCP optimizes repeatable operational-context handling, so the public evidence keeps the repeated context controlled instead of turning the benchmark into a different conversation every run.
The public v1.0.x evidence combines reproducible verification fixtures with live MCP runtime validation across the runtimes listed above. It reports context compression, repeated-pack avoidance with known_pack_hash, lazy initialization, minimal tool surface, explicit read-only mode safety, response diet, local telemetry, closure control, and a sub-agent handoff example.
See: Verification Evidence and v1.0.0 Results.
codex-agent-mem runs in Claude Code as a standard MCP stdio server. It does not install session-start hooks, stop hooks, or automatic post-turn summarization. Memory is retrieved on demand through MCP tools such as mem_context_pack, mem_search, mem_open_work, and mem_completion_check.
If you already use claude-mem, both tools can technically coexist. For lower-overhead, lower-latency workflows, use one active memory layer at a time. In local validation with one Claude Code host active, codex-agent-mem alone kept the runtime compact (same_db_process_count=2, spawn_storm_warning=false). Running it alongside claude-mem increased visible tool surface to 61 tools, added a session-start memory block of about 6,995 tokens, and showed post-turn stop-hook delays. This does not break codex-agent-mem, but it makes results harder to compare and can increase overhead and latency.
Use codex-agent-mem when you prefer local-first, auditable, pull-based memory with explicit retrieval and deterministic closure checks. Use additional memory plugins only when you intentionally want their automatic hook-based behavior.
For token-sensitive Claude Code workflows, codex-agent-mem is designed for low overhead by default: no session-start injection, no stop-hook summarization, compact responses, explicit budgets, and pack_hash / not_modified short-circuiting for unchanged packs.
codex-agent-mem v1.0.1 and clean-process-ended (GitHub) v0.7.2 work independently, but they solve adjacent problems in local agent workflows.
codex-agent-mem preserves continuity: project memory, scoped context packs, manual notes, snapshots, open work, blockers, and deterministic closure checks.clean-process-ended handles local process hygiene: ownership-first diagnostics, dry-run close checks, and compact janitor receipts.Together they improve end-of-task workflows: recover context, finish the work, check local process state, and store compact close evidence without making either MCP a hard dependency of the other.
AGENTS.md working packs when compression is actually favorablenotify and optional AGENTS.md sync remain available where usefulmem_open_work and mem_completion_check so open work beats stale completion claims/ui lets you navigate recent changes, scope guard, provenance, health, snapshots, governance state, and stored memory without opening the SQLite database by handKey docs: AGENTS.md | Quickstart | Codex Integration | Codex Desktop Note | Support Matrix | Design Decisions
Built for long audits, multi-step project continuity, and workflows where the real failure mode is not only forgetting decisions, but also dropping scope, losing blockers, and declaring completion too early.
1.0.2 is the current 1.0.x maintenance release. 1.0.0 remains the public verification baseline for the reproducible metrics below.
What works today:
notify ingestion on agent-turn-completesession_summary, decision, objective, constraint, pending_item, completed_item, blocker, and completion_claimproject_dod, mission_dod, and session_dodmicro, normal, and full reinjectionAGENTS.md sync through --sync-project-doc when the generated pack is smaller than the source contextmem_open_work and mem_completion_checkmem_recent_changesmem_scope_guardbudget=automem_provenancemem_healthmem_health_runtimemem_note_create, indexed for mem_search and eligible for mem_context_packmem_snapshot_create, mem_snapshot_list, and mem_snapshot_restoremem_policy_validate, mem_policy_add, mem_policy_list, and mem_policy_removemem_inheritance_add, mem_inheritance_list, and mem_inheritance_removemem_repair_propose and mem_repair_apply--profile minimal|standard|full--read-onlystructuredContentknown_pack_hash / not_modified continuity-pack reuse--telemetry-mode off|summary|debugcodex-agent-mem-daemon and stdio bridge mode with --daemon-url/ui, including recent changes, scope guard, provenance, health, snapshots, and governance statecodex-agent-mem-policymem_searchmem_getmem_recentmem_session_listmem_scope_resolvemem_bootstrap_contextmem_project_briefmem_open_workmem_completion_checkmem_recent_changesmem_scope_guardmem_context_packmem_provenancemem_healthmem_health_runtimemem_snapshot_listmem_note_createmem_snapshot_createmem_snapshot_restoremem_policy_listmem_policy_validatemem_policy_addmem_policy_removemem_inheritance_listmem_inheritance_addmem_inheritance_removemem_repair_proposemem_repair_applyWhat is intentionally not in scope yet:
codex-agent-mem is installed as a local Python package and exposed to MCP-compatible clients through stdio commands.
The stable pattern is:
Codex-specific notify and mcp_servers snippets are generated by codex-agent-mem-bootstrap-codex; other MCP clients use their own configuration files.
If you want the shortest path from clone to a working local setup:
git clone https://github.com/MarceloCaporale/codex-agent-mem.git
cd codex-agent-mem
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -e .[dev]
codex-agent-mem-smoke
codex-agent-mem-bootstrap-codex --db-path C:\Users\YOU\.codex_agent_mem\codex_agent_mem.db
git clone https://github.com/MarceloCaporale/codex-agent-mem.git
cd codex-agent-mem
python3 -m venv .venv
source .venv/bin/activate
pip install -e .[dev]
codex-agent-mem-smoke
codex-agent-mem-bootstrap-codex --db-path "$HOME/.codex_agent_mem/codex_agent_mem.db"
For Codex, paste the generated snippet into ~/.codex/config.toml. For other MCP clients, use the common stdio command in Configure MCP clients.
pipx from GitHubInstall directly from the repository URL:
pipx install "git+https://github.com/MarceloCaporale/codex-agent-mem.git"
codex-agent-mem-smoke
pipx install "git+https://github.com/MarceloCaporale/codex-agent-mem.git"
codex-agent-mem-smoke
git clone https://github.com/MarceloCaporale/codex-agent-mem.git
cd codex-agent-mem
python3 -m venv .venv
source .venv/bin/activate
pip install -e .[dev]
pytest -q
codex-agent-mem-smoke
git clone https://github.com/MarceloCaporale/codex-agent-mem.git
cd codex-agent-mem
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -e .[dev]
pytest -q
codex-agent-mem-smoke
The MCP server entry point is the same for every compatible client:
codex-agent-mem-mcp --db-path "$HOME/.codex_agent_mem/codex_agent_mem.db"
codex-agent-mem-mcp --db-path C:\Users\YOU\.codex_agent_mem\codex_agent_mem.db
Point your MCP-capable client at that installed stdio command. The validated public v1.0.x paths include Codex CLI/Desktop, Claude Code, Google Gemini CLI, Qwen Code with local Qwen models through Ollama, DeepSeek-V3.2 and Minimax M2.5 through Ollama Cloud, plus Kimi Code CLI connection validation.
Generate a ready-to-paste snippet:
codex-agent-mem-bootstrap-codex --db-path "$HOME/.codex_agent_mem/codex_agent_mem.db"
codex-agent-mem-bootstrap-codex --db-path C:\Users\YOU\.codex_agent_mem\codex_agent_mem.db
For Codex, that prints the notify block, the [mcp_servers."codex-agent-mem"] block, an explicit stdio idle-timeout, and MCP tool approvals you can paste into ~/.codex/config.toml.
For long-lived Codex Desktop sessions, prefer a longer MCP idle timeout such as --idle-timeout-seconds 1800 so the Desktop thread is less likely to keep a closed stdio transport. For short CLI or codex exec runs, 300 seconds is usually enough and keeps cleanup faster.
Automatic AGENTS.md reinjection is now opt-in. Add --sync-project-doc to the notify command only if you want generated working-memory blocks written back into the working directory.
Once configured, the agent should use codex-agent-mem proactively when continuity matters. You should not need to repeat "use the memory MCP" every few turns.
Recommended pattern:
mem_bootstrap_context when prior decisions, pending work, blockers, constraints, or project state may matter; pass thread, chat-title, cwd, or repo hints when the host exposes themmem_context_pack directly only when the scope is already explicit, preferably with session_id for broad workspacesknown_pack_hash on repeated checks so unchanged packs return not_modified instead of resending contextmem_search only when the compact pack is not enoughmem_open_work and mem_completion_check for implementation, validation, publishing, migration, or documentation tasksThis is where the practical token economy comes from: compact continuity first, targeted expansion only when needed, and no repeated pack when nothing changed.
Example files live under examples/codex, with Ollama workflow notes under examples/ollama.
Start the inspection API:
codex-agent-mem-api --db-path "$HOME/.codex_agent_mem/codex_agent_mem.db"
codex-agent-mem-api --db-path C:\Users\YOU\.codex_agent_mem\codex_agent_mem.db
Then open:
http://127.0.0.1:37770/ui
Start the MCP server:
codex-agent-mem-mcp --db-path "$HOME/.codex_agent_mem/codex_agent_mem.db"
codex-agent-mem-mcp --db-path C:\Users\YOU\.codex_agent_mem\codex_agent_mem.db
The current MCP transport is stdio. That means one process per host connection is normal; it is not a singleton daemon. The defensive idle timeout is there to let unused or orphaned instances exit cleanly.
Recommended defaults: use a longer timeout for Codex Desktop sessions, for example 1800 seconds, and a shorter timeout for CLI/ephemeral runs, for example 300 seconds.
Manually rebuild the generated continuity block for one directory:
codex-agent-mem-refresh-context --db-path "$HOME/.codex_agent_mem/codex_agent_mem.db" --project-key YOUR_PROJECT --cwd /path/to/project
codex-agent-mem-refresh-context --db-path C:\Users\YOU\.codex_agent_mem\codex_agent_mem.db --project-key YOUR_PROJECT --cwd C:\Path\To\Project
Run the smoke test:
codex-agent-mem-smoke --db-path "$HOME/.codex_agent_mem/codex_agent_mem.db"
codex-agent-mem-smoke --db-path C:\Users\YOU\.codex_agent_mem\codex_agent_mem.db
That inserts a sample turn, extracts observations, and verifies recent retrieval and project brief generation.
--sync-project-doc is enabled and that pack is actually smaller than the source context, it is synced into AGENTS.md for the working directory.AGENTS.md sync let future sessions start with compressed continuity instead of forcing you to restate old scope.mem_context_pack exposes the same compact pack over MCP for on-demand retrieval.This is token efficiency for agent workflows, not magic compression. codex-agent-mem improves the token economy by reducing repeated project context, reusing unchanged packs through known_pack_hash, and letting agents expand only the memory they need.
In plain language: this usually aims to cut down the amount of repeated context you have to replay, not to eliminate it completely.
What we can say honestly from local validation:
95.35% in that controlled scenario86% and 97% reductionExamples from the public v1.0 verification sandbox:
1,841 -> 253 approximate tokens4,855 -> 270 approximate tokens9,731 -> 269 approximate tokens6,523 -> 276 approximate tokensImportant: this is not a fixed guarantee per prompt. If the compact pack is not actually smaller than the source context, codex-agent-mem skips reinjection instead of pretending it saved tokens.
This repository includes:
pyproject.tomlCreated and maintained by Marcelo Caporale.
A trilingual (繁中 / English / 简中) learning roadmap for agentic AI: from LLM basics to multi-agent systems, with 240+ cura
Run Claude Code as an MCP server so any agent can delegate coding tasks to it
Browser automation using accessibility snapshots instead of screenshots
MCP server integration for DaVinci Resolve Studio