Codex
Connect Codex with the Lore plugin, lifecycle hooks, and the memory MCP server.
The Codex integration gives Codex startup memory at the start of each session, recall before each prompt, and the Lore memory tools through MCP. It installs a local Codex plugin, turns on Codex hooks, and registers the lore MCP server.
Install
Run this on the machine where you use Codex:
npx @loremem/cli install --channels codexOn Loremem Cloud, pass the server and your project token:
npx @loremem/cli install --base-url https://api.loremem.com --api-token lm_your_token --channels codexThe installer skips Codex when the codex command is not on your PATH. It writes Codex files under CODEX_HOME, which defaults to ~/.codex.
What gets installed
- The plugin from
lore-codex.zip. The installer stages it in~/.lore/codex/, registers that folder as a local marketplace withcodex plugin marketplace add, and copies the plugin to$CODEX_HOME/plugins/cache/lore/lore/local/. - Two hooks, bundled with the plugin.
SessionStart, which runs onstartup,resume, andclear, loads startup memory.UserPromptSubmitadds recall to each prompt. Each hook has a 10-second timeout. - The
loreMCP server at<server>/api/mcp?client_type=codex, registered withcodex mcp addand written toconfig.toml. - The bundled
skills/directory, which the SessionStart hook fills with the skills Codex may use:$skill-nameor/skillsruns one. - A bundled
lore-memoryskill. It tells Codex to loadlore_guidanceandlore_bootwhen a task depends on durable context. - Hook entries from earlier Lore installs are removed from
$CODEX_HOME/hooks.json. Other hooks in that file stay.
The installer writes config.toml with mode 0600 and sets these sections:
[plugins."lore@lore"]
enabled = true
[features]
hooks = true
[mcp_servers.lore]
url = "https://api.loremem.com/api/mcp?client_type=codex"
http_headers = { Authorization = "Bearer lm_your_token" }The http_headers line appears only when you set a token. The token is stored in that header, so keep the file private.
Verify
- Run
npx @loremem/cli status. Thecodexline should readinstalled. - Run
codex mcp list. It should listlore. - Start Codex and open
/plugins. If Lore is still listed as installable, install it from there. - Open
/hooksand trust the Lore hooks if Codex asks. - Start a new session and ask Codex to call
lore_status. It should return the server's health. - Send a prompt about a project that has memories. The context should include a
<recall>block.
Notes
-
Trust the hooks. If Codex reports that the hooks need review, open
/hooksand trust the Lore hooks. -
Older Codex builds. Legacy Codex builds need user-level hook entries in
~/.codex/hooks.json. For those builds, run the installer withLORE_CODEX_INSTALL_USER_HOOKS=1:LORE_CODEX_INSTALL_USER_HOOKS=1 npx @loremem/cli install --channels codexThis adds Lore's hook entries to
$CODEX_HOME/hooks.json. It keeps the other hooks in that file. -
Restart after changes. Hooks and MCP settings load at process start. Restart Codex after you change
config.toml, the hooks, or the token.
Manual setup (fallback)
This method adds the memory tools through MCP only. It doesn't install the hooks, so Codex gets no startup memory and no recall. Use the installer when you need those.
codex mcp add lore --url "https://api.loremem.com/api/mcp?client_type=codex"If your server needs a token, add the server to ~/.codex/config.toml instead of using the command. Use either the command or the TOML block, not both. Keep the file readable only by you (chmod 600 ~/.codex/config.toml).
[mcp_servers.lore]
url = "https://api.loremem.com/api/mcp?client_type=codex"
http_headers = { Authorization = "Bearer lm_your_token" }Uninstall
npx @loremem/cli uninstall --channels codex -yThis removes the Lore marketplace, the lore and lore-skills MCP entries, the Lore sections in config.toml, and the Lore hook entries in hooks.json. Other hooks stay. It also deletes ~/.lore/codex and Lore's plugin cache. Restart Codex afterwards.
If Codex doesn't load Lore, see Agent connection issues.