代码生成服务

Codex CLI MCP Server (Ollama) 是一个支持多模型的代码生成服务,通过本地或远程Ollama实例路由代理编码任务。

  • by PushPullCommitPush
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 PushPullCommitPush/MCP_CLI_CODEX

使用说明

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