Back to Documentation
OpenAI logo

Codex CLI Integration

Use ContextFS with OpenAI Codex CLI via MCP

Prerequisites

Before configuring ContextFS with Codex CLI, ensure you have:

  • Codex CLI installed - Install via npm install -g @openai/codex
  • ContextFS CLI installed - Install via pip install contextfs or uv tool install contextfs
  • OpenAI API key - Required for Codex CLI authentication

MCP Configuration

1. Create the MCP configuration file

Add ContextFS to your Codex CLI MCP configuration at ~/.codex/mcp.json:

{
  "mcpServers": {
    "contextfs": {
      "command": "contextfs",
      "args": ["mcp", "serve"],
      "env": {}
    }
  }
}

2. Verify the configuration

Start Codex CLI and verify ContextFS tools are available:

# Start Codex CLI
codex

# The contextfs tools should now be available:
# - contextfs_search
# - contextfs_save
# - contextfs_recall
# - contextfs_list

3. Test the integration

Try searching for memories in a Codex session:

# In your Codex session, ask:
"Search my memories for authentication patterns"

Available MCP Tools

Once configured, Codex CLI has access to these ContextFS tools:

contextfs_search

Search memories using hybrid semantic + keyword search

contextfs_save

Save new memories (facts, decisions, procedures, errors)

contextfs_recall

Recall a specific memory by ID

contextfs_list

List recent memories with optional filtering

contextfs_evolve

Update an existing memory while preserving history

Cross-Tool Sync

To share memories between Codex CLI and other tools (like Claude Code), enable cloud sync:

# Login to ContextFS cloud
contextfs cloud login

# Enable sync
contextfs cloud sync

# Memories will now sync across all your connected tools

Next Steps

To get the most out of ContextFS with Codex CLI:

  • • Enable cloud sync to share context across all your AI tools
  • • Use contextfs memory auto-recall to automatically load relevant context
  • • Save important decisions and procedures as you work
  • • Index your repositories with contextfs index for better code search