AI Coding Harnesses & IDE Setup · 7 min read

OpenAI Codex CLI MCP Config: Persistent Memory & Blast-Radius Tools

Configure MCP in OpenAI Codex CLI (~/.codex/config.toml). Enable Memoreal persistent memory, RFC 8628 browser OAuth pairing, and symbol blast-radius tools.

Direct Answer (TL;DR) Self-Contained GEO Passage

OpenAI Codex CLI uses a TOML-based configuration file located at ~/.codex/config.toml to define external MCP servers. Adding Memoreal MCP equips Codex subagents with cross-turn memory persistence, symbol blast-radius tools, and RFC 8628 headless browser OAuth pairing. This prevents context amnesia during complex multi-step terminal tasks and ensures consistent rule adherence across autonomous agent sessions.

RFC 8628
OAuth 2.1 Device Authorization Grant for headless terminal authentication
IETF OAuth Standards
31 Tools
Cloud MCP tools available to Codex CLI subagents and planners
Memoreal Specification
0 Token Tax
No extra LLM inference tokens billed during memory retrieval
Memoreal Pricing Model
Table of Contents ↓

OpenAI Codex CLI Memory Options Comparison

OpenAI Codex CLI Memory Options Comparison
Feature / AspectNative Codex CLICodex CLI + Memoreal MCPOperational Benefit
Configuration Location~/.codex/config.toml~/.codex/config.toml [mcp_servers.memoreal]Native TOML configuration file integration
Authentication MethodAPI Keys or ChatGPT OAuthRFC 8628 Device Flow or MEMOREAL_API_KEYSecure browser pairing on remote SSH and containers
Session MemoryEphemeral subagent contextPersistent 4-tier cognitive memorySubagents retain decisions across multiple CLI turns
Code IntelligenceGreps and filesystem readsAST search_code, impact, and call_treeReduces multi-file token consumption by up to 70%

How OpenAI Codex CLI Interacts with Model Context Protocol Servers

OpenAI Codex CLI provides a powerful terminal interface for autonomous software engineering, allowing developers to spawn background subagents, execute unit tests, and refactor complex multi-module systems.

By default, Codex subagents operate with an ephemeral memory buffer that resets when a task concludes. By wiring Codex to an external MCP server, subagents can record their findings, review historical bug causes, and pass structured handoff payloads to subsequent worker processes.

  • Codex CLI parses MCP server definitions from the ~/.codex/config.toml configuration file.
  • Subagents can autonomously invoke MCP tools to query past architectural precedents before writing code.
  • Persistent memory reduces repetitive prompt explanations across independent CLI executions.

Configuring ~/.codex/config.toml with Memoreal Persistent Memory

To enable Memoreal in Codex CLI, open or create ~/.codex/config.toml in your home directory. Add a dedicated [mcp_servers.memoreal] block specifying the executable command and arguments.

The standard configuration uses npx to run @kolivri/memoreal-mcp on demand. You can pass your MEMOREAL_API_KEY inside the [mcp_servers.memoreal.env] table, or omit it if you prefer authenticating interactively via browser OAuth on your workstation.

  • Ensure TOML table headers correctly match [mcp_servers.<name>] syntax.
  • Environment variables defined in the configuration are automatically passed to the spawned process.
  • You can run codex mcp test memoreal to verify process spawning and tool discovery.

RFC 8628 Headless Terminal Authentication and Pairing

When running Codex CLI in headless cloud environments, Docker containers, or remote SSH sessions, manually copying and pasting long secret API keys can be insecure and awkward.

Memoreal supports RFC 8628 (OAuth 2.1 Device Authorization Grant). When you initiate pairing, the CLI displays a short, human-friendly 8-character verification code and a pairing URL. Visiting the URL in any authenticated browser approves the CLI session instantly, establishing an encrypted token pair without leaking secrets to terminal scrollback.

  • RFC 8628 eliminates the need to expose long-lived production secrets in plaintext config files.
  • Pairing works seamlessly through jump hosts, cloud devboxes, and remote devcontainers.
  • Tokens can be revoked immediately from the Memoreal cloud management dashboard if a laptop is lost.

Configuring Memoreal MCP in ~/.codex/config.toml

toml
# ~/.codex/config.toml
# Register Memoreal persistent memory and code intelligence server

[mcp_servers.memoreal]
command = "npx"
args = ["-y", "@kolivri/memoreal-mcp@latest"]

[mcp_servers.memoreal.env]
MEMOREAL_API_KEY = "mem_live_YOUR_API_KEY"

Frequently Asked Questions

Does Codex CLI support hot-reloading MCP configuration changes in config.toml?

Codex CLI reads config.toml at startup. If you edit the configuration file while a session is running, you must exit and restart the CLI to establish new MCP connections.

Can Codex CLI subagents share memory with Cursor Composer or Claude Code?

Yes, because Memoreal indexes memories in a unified cloud or team workspace namespace, memories recorded by Codex CLI in your terminal are immediately accessible in Cursor and Claude Code.

What is the advantage of using blast-radius tools like impact in Codex CLI?

Instead of scanning dozens of files using grep or reading entire directories into context, the impact tool uses AST call graphs to return exact upstream callers in under 15ms, saving thousands of tokens.

60-Second Setup

Install Persistent Memory for Your Coding Agent

Sub-15ms deterministic recall, AST symbol navigation, and 70%+ token savings across Claude Code, Cursor, Codex CLI, and Windsurf.

npx -y @kolivri/memoreal-mcp setup
Start Free (1,000 Calls · $0 LLM Tax) Compare All Alternatives →