A second brain for Codex

Codex ships with AGENTS.md and a goldfish memory. Wire it to a brain and your project knowledge stops evaporating at the end of every run.

Last updated

AIVM Brain connects to OpenAI Codex as an MCP server. Codex gains governed recall over everything your brain holds: decisions, docs, conventions, past fixes. Add one server block to Codex's MCP configuration and every session can query and capture knowledge, with permissions enforced and every access recorded.

Wire Codex to your brain

Codex talks to the brain over MCP, the same protocol it uses for any external tool. Generate a key in the dashboard, then add the server to Codex's MCP configuration (the Codex CLI reads it from ~/.codex/config.toml as of mid-2026; see OpenAI's docs for your version).

  1. Generate your key. Sign up free at brain.aivm.io, open Connect, pick Codex. The dashboard mints your agent key and shows the exact server config.

  2. Add the MCP server. These are the values, shown here as the standard JSON shape. In config.toml the same three fields (command, args, env) go under an mcp_servers entry:

    {
      "mcpServers": {
        "aivm-brain": {
          "command": "npx",
          "args": ["-y", "@aivm/brain", "serve"],
          "env": {
            "AIVM_BRAIN_URL": "https://brain.aivm.io",
            "AIVM_AGENT_KEY": "ak_your_key"
          }
        }
      }
    }
  3. Test recall. Ask Codex to store a fact in the brain, start a fresh session, and ask for it back. If it answers cold, it works.

AGENTS.md tells Codex how. A brain tells it what you know.

AGENTS.md is the right place for instructions: how to run tests, what style to follow, where things live. But it is written by hand and frozen until someone edits it. The knowledge that actually compounds on a project is different: why the retry logic looks weird, which API the team decided to deprecate, what the customer actually asked for. That is what the brain holds, and Codex can pull exactly the piece it needs mid-task instead of you pasting context into every prompt.

Because it is a governed store rather than a scratch file, that knowledge survives the machine, the repo, and the person. A new engineer's Codex inherits the project's memory on day one, minus whatever their role is not cleared to see.

Cloud runs and CI need memory most

Codex increasingly runs where you are not: delegated tasks, cloud sandboxes, CI jobs. Those runs start from nothing unless their context is provisioned. A brain over MCP gives a headless Codex run the same recall your interactive session has, and the audit ledger shows you afterwards exactly what it read to do the job. When an autonomous agent touches company knowledge, that record is the difference between trust and hope.

Questions, answered

Does this work with both the Codex CLI and Codex in the cloud?

The brain is a standard MCP server, so it works anywhere Codex can be configured with MCP servers. The CLI path is the straightforward one; for cloud environments, follow OpenAI's MCP configuration docs for that surface.

Should I replace AGENTS.md?

No, keep it. AGENTS.md is for stable instructions. The brain is for accumulated knowledge: decisions, fixes, and facts that change weekly. They complement each other.

Is anything I store used for model training?

No. Bring your own model key for AI features, and nothing you store trains any model. Storage is per-tenant with row-level isolation.

Can my team's other agents read what Codex stores?

Yes, if their keys are cleared for it. That is the point: one brain, many agents, each seeing only what its role allows, with every access logged.

What happens if a key leaks?

Rotate it from the dashboard. Keys are scoped per member and per agent, and the ledger shows exactly what any key touched, so the blast radius is visible instead of guessed.

Keep reading

Give Codex a brain it can be held to.