Codex CLI

•

Wraps OpenAI's Codex CLI with Ollama backend support, enabling agentic coding tasks to be routed through local or remote models.

Codex CLI is an MCP server designed to extend the capabilities of OpenAI's Codex CLI by integrating with Ollama, allowing users to leverage a variety of local or remote large language models for agentic coding tasks. It facilitates a powerful development workflow by supporting multi-model profiles, session persistence, sandboxed file operations, and seamless compatibility with MCP-enabled clients like Claude Desktop, Cursor, and OpenWebUI.

主要功能

01Multi-model profiles for task-specific model selection
02Ollama integration for local or remote model usage
03MCP Protocol compatibility with various clients
04Session persistence to resume conversations
050 GitHub stars
06Sandboxed file operations within a safe working directory

使用案例

01Executing agentic coding tasks with various local or remote large language models.
02Switching between specialized AI models for different programming tasks, such as code generation, review, or quick fixes.
03Integrating advanced AI coding capabilities into existing MCP-compatible development environments like Claude Desktop.

Codex CLI MCP Server (Ollama)

MCP server that wraps OpenAI's Codex CLI with Ollama backend support. Route agentic coding tasks through your own local or remote models.

Features

  • Multi-model profiles — Switch between models per task (fast ops, heavy reasoning, coding, security review)
  • Ollama integration — Use any model running on localhost:11434 or remote Ollama instance
  • Session persistence — Resume conversations with codex_resume
  • Sandboxed file ops — Read/write/list within a safe working directory
  • MCP Protocol — Works with Claude Desktop, Cursor, OpenWebUI 0.7+, and any MCP-compatible client

Tools

Tool Description
codex_run Run a prompt with profile/model selection
codex_resume Continue the last session
codex_profiles List available models
fs_read Read file from workdir
fs_write Write file to workdir
fs_list List workdir contents

Default Profiles

  • default — Codex Max (default model)
  • fast — OSS 20B (quick tasks)
  • heavy — OSS 120B (complex tasks)
  • reasoning — DeepSeek v3.1 (chain-of-thought)
  • coder — Qwen3 Coder 480B (code generation)
  • security — Kimi K2 (code review, sandboxed)

Note: The Kimi K2 / security profile may cause issues depending on your setup. If you experience hangs or errors, consider removing or replacing it in the PROFILES object.

Environment Variables

  • CODEX_WORKDIR — Working directory (default: ~/codex-work)
  • CODEX_PATH — Path to Codex CLI (default: /opt/homebrew/bin/codex)
  • OLLAMA_URL — Ollama API endpoint (default: http://localhost:11434/v1)

Requirements

  • Node.js
  • Codex CLI installed
  • Ollama running with your models pulled

Installation

git clone https://github.com/PushPullCommitPush/MCP_CLI_CODEX.git
cd MCP_CLI_CODEX
npm install  # no dependencies, but creates package-lock

Usage

Standalone

node index.js

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "codex": {
      "command": "node",
      "args": ["/path/to/MCP_CLI_CODEX/index.js"],
      "env": {
        "CODEX_WORKDIR": "/path/to/workspace"
      }
    }
  }
}

With custom workdir

CODEX_WORKDIR=/my/project node index.js

Customization

Edit the PROFILES object in index.js to match your Ollama models:

const PROFILES = {
  default: { name: 'Default', model: 'your-model-name', provider: 'ollama' },
  // Add your own profiles...
};

License

MIT