Short answer

Keep project instructions in AGENTS.md. Install MESA Lore to add a local MCP memory server to Codex, approve its hooks with /hooks, then start a new session and test memory_search.

1. Separate instructions from history#

Codex reads AGENTS.md files before doing work, so use them for standards and project rules. A memory server has a different job: it helps the agent find what happened in earlier sessions.

NeedUse
Rules for every taskAGENTS.md
Earlier decisions and failuresMCP memory
A note for the next sessionHandoff in MESA Lore

2. Install the MCP memory server#

Worked example
git clone https://github.com/Yasou13/MESA_Lore.git
cd MESA_Lore
python3 -m venv .venv
.venv/bin/pip install .
.venv/bin/mesa-lore install
.venv/bin/mesa-lore doctor

Install adds a mesa-lore server to ~/.codex/config.toml, the default Codex MCP configuration, and adds session hooks to ~/.codex/hooks.json. It backs up changed files first. Codex can also read hooks from other places, such as a trusted project’s .codex/hooks.json; ~/.codex/hooks.json is the default user location.

Existing history is imported

Install also imports existing agent transcripts. Exclude private projects first.

3. Approve the hooks#

Codex requires non-managed hooks to be reviewed and trusted before they run. Open Codex, run /hooks and approve the MESA Lore commands. Without approval, automatic capture and the session-start index do not run.

4. Verify the connection#

Worked example
codex mcp list
mesa-lore doctor

codex mcp list should show mesa-lore. Inside Codex, /mcp shows active servers. mesa-lore doctor should report OK for Codex MCP and hooks.

After install and hook approval, the Codex line reads Codex MCP: OK | hooks: OK (approve with /hooks in Codex). Before setup it reads Codex MCP: missing | hooks: missing.

5. Test memory in a new session#

  1. Start a new Codex session in the project.
  2. Ask: “Call memory_index and summarize recent work.”
  3. Ask: “Search memory for the last failed test fix.”
  4. Check that the answer points to a real source.
  5. Save a decision: “Save this as a decision in memory.”
What the MESA Lore tests measured

From the mesa-lore 0.1.0 test suite and benchmark on Linux: session startup cost 432 tokens (163 for the index, 269 for tool definitions), and search p95 was 84 ms of CPU time on 10,000 chunks in one run. End-to-end token savings when resuming a session have not been measured. Search is lexical, so a query needs words or stems that appear in the transcript.

What if Codex does not use memory?#

What you seeFix
codex mcp list does not show mesa-loreRun mesa-lore install again, then check ~/.codex/config.toml
No memory index at session startApprove the hooks with /hooks, then start a new session
Codex MCP: missing in mesa-lore doctorThe MCP entry is absent. Reinstall, or restore it from the backup that install made
Search finds nothing for a known decisionUse words from the original session; search is lexical

More cases are in MESA Lore troubleshooting.

Codex memory questions#

Where does Codex store MCP settings?
By default in ~/.codex/config.toml. Trusted projects can also use .codex/config.toml.
Does MESA Lore replace AGENTS.md?
No. AGENTS.md gives instructions. Lore makes past work searchable.
Why is the memory index not appearing?
The hook may not be approved. Run /hooks, start a new session and check mesa-lore doctor.
Can Codex and Claude Code share memory?
Yes. MESA Lore stores both agents in the same local database and searches by project.

Sources#

  1. Codex · Custom instructions with AGENTS.md
  2. Codex · Model Context Protocol
  3. Codex · Hooks
  4. MESA Lore on GitHub