Skip to content

Codex Integration

MemoryLayer for Codex (memorylayer-codex-plugin, new in 0.2.0) connects Codex to MemoryLayer through the MemoryLayer MCP server. It adds a Codex skill that tells the agent when to recall prior context and when to store durable memories.

Unlike the Claude Code plugin, it has no lifecycle hooks or slash commands. It uses Codex-native skills plus MCP configuration instead. It shares the memorylayer-mcp command and the MEMORYLAYER_* environment variables with the Claude Code plugin.

What It Provides

  • MCP server configuration: Registers the memorylayer MCP server (the memorylayer-mcp command), so Codex gets the MemoryLayer tools (28 in the default cc profile)
  • The memorylayer skill: Guidance for recall, durable memory capture, sessions, and context-environment workflows
  • Shared configuration: Uses the same environment variables as the Claude Code plugin

Prerequisites

  1. A running MemoryLayer server, usually at http://localhost:61001:

    Terminal window
    pip install memorylayer-server
    memorylayer serve
  2. The memorylayer-mcp command on your PATH:

    Terminal window
    npm install -g @scitrera/memorylayer-mcp-server
  3. Optional environment variables:

    Terminal window
    export MEMORYLAYER_URL="http://localhost:61001"
    export MEMORYLAYER_API_KEY="" # optional for local/open deployments
    export MEMORYLAYER_WORKSPACE_ID="" # optional; auto-detected from the repo when empty

Installation

The Codex plugin is a plugin folder, not an npm package, and has no publish step. It lives in the MemoryLayer repository at memorylayer-codex-plugin/:

Terminal window
git clone https://github.com/scitrera/memorylayer.git

Install the memorylayer-codex-plugin folder with Codex’s plugin mechanism. The folder layout is:

PathPurpose
.codex-plugin/plugin.jsonCodex plugin manifest (memorylayer-codex-plugin, displayed as “MemoryLayer for Codex”). Points at ./skills/ and ./.mcp.json
.mcp.jsonMemoryLayer MCP server configuration
skills/memorylayer/SKILL.mdThe memorylayer skill

The bundled .mcp.json launches memorylayer-mcp and passes the environment through with defaults:

{
"mcpServers": {
"memorylayer": {
"command": "memorylayer-mcp",
"env": {
"MEMORYLAYER_URL": "${MEMORYLAYER_URL:-http://localhost:61001}",
"MEMORYLAYER_API_KEY": "${MEMORYLAYER_API_KEY:-}",
"MEMORYLAYER_WORKSPACE_ID": "${MEMORYLAYER_WORKSPACE_ID:-}"
}
}
}
}

The memorylayer Skill

The skill activates when Codex should recall or store durable project context, keep decisions across sessions, use the MemoryLayer MCP tools, or troubleshoot MemoryLayer setup. It tells Codex to:

  • Prefer workspace-scoped memories: respect MEMORYLAYER_WORKSPACE_ID when it’s set, and otherwise let the MCP server auto-detect the workspace from the repo
  • Recall before substantial work: call memory_recall or memory_briefing before broad reviews, architecture work, implementation in an unfamiliar subsystem, or recall requests
  • Store only durable, non-secret information: user directives, decisions with rationale, solved bugs, architecture tradeoffs, reusable workflows, and important task state
  • Never store secrets: credentials, API keys, private tokens, and raw confidential payloads stay out. Sensitive context is summarized at a safe level of abstraction
  • Degrade gracefully: if the MCP tools are unavailable, say MemoryLayer is not connected and continue from the local repository

Suggested tool use

ToolWhen
memory_briefingStart of a large task or review
memory_recallPreferences, prior decisions, subsystem history, or repeated bug/error work
memory_rememberRight after a decision, bug fix, benchmark result, architecture conclusion, or user directive
memory_session_start, memory_session_commit, memory_session_endLong-running agent work whose working memory should survive handoffs
memory_context_*Server-side sandbox analysis that should survive context compaction or resume after a long investigation

The skill also asks Codex to mention memory-backed context only when it materially affects the answer. The repository and its tests stay the source of truth for how the code currently behaves.

Differences from the Claude Code Plugin

Claude Code pluginCodex plugin
MCP servermemorylayer-mcpmemorylayer-mcp
Lifecycle hooks (pre-compaction capture, context packs, observation capture)YesNo
Slash commandsYesNo
Agent guidanceHooks + optional CLAUDE.md protocolmemorylayer skill

Because Codex has no MemoryLayer hooks, nothing is captured automatically before compaction. The skill has the agent store durable results explicitly, and it can call memory_session_commit or memory_session_checkpoint itself.

Troubleshooting

  • Tools not available: check that memorylayer-mcp is on your PATH (which memorylayer-mcp) and the server is reachable (curl http://localhost:61001/health).
  • Wrong workspace: set MEMORYLAYER_WORKSPACE_ID explicitly.