Guide · Codex

How to give OpenAI Codex persistent, secure memory

Codex remembers through AGENTS.md files you write and, if you turn them on, memories it keeps under ~/.codex/memories/ on your machine. For memory that is shared with Claude Code, Claude Desktop, your other machines or your team, connect Codex to a remote MCP memory server.

With Morphika that is codex mcp add morphika --url https://mcp.morphika.ai/mcp then codex mcp login morphika, which signs in through your browser.

About Morphika: Morphika is secure, shared memory for personal AI agents like Claude Code, Codex and Claude Desktop. How it is secured.

How does Codex's built-in memory work?

  • AGENTS.md is the instruction layer: Markdown files Codex reads at the start of every session. OpenAI advises keeping required team guidance there.
  • Memories are off by default. Turn them on in the app under Settings → Personalization, or with memories = true in config.toml. They are stored locally under your Codex home directory (~/.codex by default), so they are not shared across machines or people.

How do I connect Codex to Morphika?

  1. Step 1: Make sure Codex is recent (MCP sign-in needs a current version).
  2. Step 2: Add the server, then sign in. The login command opens your browser; sign in to Morphika and click Authorize.
Terminal
npm i -g @openai/codex@latest
Terminal
codex mcp add morphika --url https://mcp.morphika.ai/mcp
codex mcp login morphika

OpenAI's docs say the Codex CLI and IDE extension share this MCP configuration, so you set it up once.

How do I keep it secure?

  • No API key or bearer token goes in config.toml: Morphika signs in with OAuth 2.1 and PKCE.
  • For a read-only connection, use codex mcp add morphika-read --url https://mcp.morphika.ai/read/mcp, then codex mcp login morphika-read. It can read and search but never write.
  • Anything that looks like a credential is refused before it is saved, and secrets are masked in results.
  • Revoke the connection at any time from the dashboard, under Connectors.

Does Codex share memory with Claude Code?

Through Morphika, yes. Both connect to the same memory, so an entry Claude Code saves is one Codex can find, and the reverse. See one memory for all your agents.

Should I still use AGENTS.md?

Yes. Keep rules that must always apply in AGENTS.md, in the repository. Use Morphika for knowledge that crosses repositories and tools, and for anything a team should approve before it changes.

Sources

Related guides

Published September 25, 2026 · Last updated