Context for AI coding agents · Claude Code, Codex, MCP
Your agent read the code. Then the code changed.
memex is an open-source MCP server and hook service (memex-mcp) that keeps your coding agent’s engineering context current as the code changes. It knows what each Claude Code or Codex session was told, notices when the evidence behind it moves, and corrects the agent before the affected edit lands.
def find_name(user_id): return USERS.get(user_id) raise LookupError(user_id)
memex: since this session was last given context, its evidence changed. - changed: c-contract@r1 was supported, now unsupported Files changed since you received them: directory.py. Re-read them before continuing.
One change, two agents, sixty seconds.
A teammate pushes. memex notices the evidence moved, holds the edit that depended on it, and tells each session what to re-read.
Context with a memory of what it promised.
Retrieval tells an agent what is true now. memex also remembers what each session was already told, so it can say exactly what stopped being true, and when.
- What the session was told
- What the code says now
- What still holds
Six stages from a changed byte to a held edit.
Every check runs the same six deterministic stages: read the source, record a view, verify each claim against its evidence, deliver to the session, recheck before an edit, and correct the agent when something it was told no longer holds.
01 Capture
Two matching listings and reads of every permitted source, with HEAD, or no view at all. Drift during capture is rejected, not averaged.
memex/runtime/views.pyEMITS → stable source capture02 Index
Each capture becomes an immutable repository view. The graph commit precedes the local acknowledgement, and an already published view is never rewritten.
memex/runtime/coordinator.pyEMITS → RepositoryView, structure03 Verify
Every claim is checked against the evidence it cites, at this view: hashes, symbols, tests, approvals and supersession. Deterministic, with no model in the loop.
memex/runtime/verification.pyDERIVES → supported · needs_revalidation · unsupported04 Deliver
A bounded packet goes into the session, marked so it can be found again. It counts as delivered only when the client's own transcript shows it arrived whole.
memex/integrations/host_adapter.pyHOLDS → what each session was told05 Check
Before a declared edit, its targets and the evidence behind delivered claims are rechecked against the current view, through a long-lived hook service.
memex/runtime/actions.pyDECIDES → proceed · replan · unknown06 Correct
An affected edit is held, and the correction names what changed and what to re-read. If memex cannot check, the edit proceeds and the agent is told so.
memex/integrations/host_adapter.pyEMITS → correction, change notice
Claude Code and Codex, side by side.
Each session gets its own correction. Worktrees stay isolated, and unrelated edits pass untouched.
| Capability | Claude Code | Codex |
|---|---|---|
| Working set at session start, confirmed from the client’s record | Yes | Yes, in app-server (IDE and desktop) sessions |
| Held edit and correction | Edit, Write, MultiEdit, NotebookEdit | apply_patch |
| Change notice when a session resumes | Yes | Yes |
| Concurrent sessions, worktrees and shared checkouts | Yes | Yes |
| Guarded writes (opt-in) | Through guard_read / guard_write | Same |
| Shell edits | Reported, never certified | Same |
What memex will not pretend.
A context layer that overstates itself is worse than none. These limits are part of the design.
- It fails open. If memex cannot check, the edit proceeds and the agent is told freshness is unknown.
- It never grants permission. It can only hold an edit and ask the agent to reconsider.
- Shell writes, editors and other tools bypass the hooks; their changes are seen at the next check, not prevented.
codex execruns no hooks, so it gets no context and no checks.- Legacy v0.9 knowledge is imported as
legacy_unverifiedand never shown as current.
Preregistered, and published in full.
Every evaluation freezes its definitions and thresholds before the first trial, runs on real clients, and is published with its data.
Read the results, gate by gate →- Mechanism suite
- 16 of 16 fixturesStale evidence, supersession, worktree isolation and authority, with no isolation or authority violation.
- Native clients
- Claude Code and CodexLive together, with delivery confirmed from each client’s own session record.
- Confirmatory run
- 480 trialsFive comparison arms across 48 held-out histories on both hosts, analysed once against frozen thresholds. Five gates passed; efficacy, precision and latency did not.
Questions people ask first.
Short, direct answers about what memex is, what it needs, and what it has and has not been shown to do.
What is memex?
memex (memex-mcp on PyPI, stifler-memex-mcp on npm) is an open-source MCP server and hook service for AI coding agents. It binds each claim about your repository to the source bytes behind it, records what each Claude Code or Codex session was told, and when that evidence changes, holds the affected edit and tells the agent what to re-read. MIT licensed, by Hill Patel.
Which coding agents does memex work with? Does it work with Cursor?
Held edits, corrections and change notices work in Claude Code and Codex, through hooks installed in the repository’s own project settings. In Codex they need app-server (IDE or desktop) sessions, because codex exec runs no hooks. Other MCP clients, Cursor included, can connect to the memex MCP server for explicit lookups, but they get no held edits or corrections.
Does memex need Neo4j?
Yes. memex keeps its repository views in a Neo4j 5 server you already run, and does not replace or change your datastore. Docker is not required. If Neo4j is not running, the MCP server still answers the client’s handshake; tool calls say Neo4j is unreachable and how to fix it, and work again as soon as it answers, without a restart.
What happens if memex is down or cannot check an edit?
memex fails open. If a hook times out or errors, or memex cannot check, the edit proceeds and the agent is told freshness is unknown. memex never grants permission; it can only hold an edit and ask the agent to reconsider. memex v1 rollback turns it off at once and keeps the journal and evidence, so memex v1 mode live can resume later.
How is memex different from Mem0 or RAG memory?
Memory and retrieval tools such as Mem0 recall what looks relevant now. memex is not a personal-memory service and does not ingest transcripts. It tracks the evidence behind each claim it delivered and which session received it, so when a change makes that claim stale, the session that relied on it is corrected before its next affected edit. Retrieval says what is true now; memex also says what stopped being true, and who was told.
Is memex free?
Yes. memex is open source under the MIT licence and published free on PyPI (memex-mcp), npm (stifler-memex-mcp) and the MCP Registry (io.github.STiFLeR7/memex). It runs on your machine against your own Neo4j, and uses your host client logged in as usual: memex never asks for or stores its credentials.
Does memex make coding agents more accurate or faster?
That is not shown. In the preregistered S05 run of 480 trials, five gates passed and three failed: efficacy, because the baselines that already gave agents correct context had no stale failures left to reduce; precision, because comment-only changes caused 8 incorrect corrections; and latency, with a warm check p95 of 275 ms against a 200 ms threshold. Read the full results.
How do I install memex?
pip install memex-mcp (or npx stifler-memex-mcp), then in your repository run memex v1 install claude (or codex), memex v1 doctor, optionally memex v1 mode shadow for a first week, and memex v1 mode live. You need Python 3.11+, Git and a reachable Neo4j 5. The setup guide has every step.
A few commands per repository.
memex uses the Neo4j you already run and installs hooks only into the repository’s own project settings. Start in shadow mode to see what it would correct without changing anything.
- Python 3.11+, Git and a reachable Neo4j 5
- Your host client, logged in as usual. memex never asks for its credentials
memex v1 rollbackturns it off at once
# once pip install memex-mcp # in your repository memex v1 install claude # or: codex memex v1 doctor memex v1 mode shadow # optional first week memex v1 mode live
Give your agents a memory of what they were told.
Open source, MIT. Works with the Neo4j you already run, and never touches your client credentials.