Token导航 LogoToken导航TokenDH.com
Openai Codex MCP logo
开发工具未说明官方级别未说明来源级核验

Openai Codex MCP

MCP Server

An MCP server to communicated with, use, and wrap the API for the OpenAI Codex CLI tool.

工具数

0

提示词数

0

GitHub Stars

53

资源数

0
代码生成PythonClaudeClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

agency-ai-solutions

提供方

agency-ai-solutions

最后核验

2026/5/18 04:06

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

openai codex mcp

一个MCP服务器,用于包装OpenAI Codex CLI工具,以便与Claude Code一起使用。

概述

该项目提供了一个简单的JSON-RPC服务器,允许Claude Code与OpenAI Codex CLI工具进行交互。这使得Claude Code能够在需要时使用OpenAI的模型进行代码生成、解释和解决问题。

视频演示

https://www.loom.com/share/5d9532a79ae24b309af08c1727156f9c?sid=d9277b91-bf8c-43ec-a3c6-dc69fc52e1d2

最近的改进

MCP服务器已得到增强,可提供更直观、更强大的界面:

  1. 专业方法:为常见编码任务添加了专用方法:

- write_code:用指定语言为特定任务生成代码 - explain_code:获取代码工作原理的详细解释 - debug_code:查找并修复有问题代码中的错误

  1. 模型选择:具有默认值的明确定义的模型选项:

- o4迷你 - o4预览 - o4-pro - o4最新

  1. 简化语法:更直观的参数命名和结构,便于集成

这些改进使Claude Code更容易将OpenAI的模型用于特定的编程任务,而不需要复杂的提示工程。

先决条件

  • Python 3.12+
  • OpenAI Codex命令行界面工具(npm install -g @openai/codex)
  • 有效的OpenAI API密钥(适用于Codex CLI,不适用于此服务器)

安装和设置

本项目使用PEP‑621 pyproject.toml请按照以下步骤操作:

# 1. Create & activate a venv
uv venv                     # creates a .venv/ directory
source .venv/bin/activate   # on Windows: .\.venv\Scripts\activate

# 2. Install package and dependencies into the venv
uv pip install .

安装后 codex_server 入口点在您的PATH中可用。

运行服务器

快速开始

使用提供的安装脚本自动设置环境并启动服务器:

./setup_and_run.sh

此脚本将:

  • 检查 codex CLI安装
  • 如果需要,设置Python虚拟环境
  • 如果可用,通过Claude CLI安装MCP工具
  • 启动MCP服务器

手动启动

如果您更喜欢手动启动服务器:

  1. 确保Codex CLI已安装并使用OpenAI API密钥正确配置
  2. 启动服务器:
   codex_server

*或者,直接使用uvicorn:* uvicorn codex_server:app

与Claude Code集成

MCP服务器运行后,您可以使用以下任一方法向Claude Code注册它:

方法1:使用Claude CLI(推荐)

该存储库包含一个配置文件,可以使用Claude CLI直接安装:

# Install the MCP tool directly from the JSON config
claude mcp add /path/to/openai_codex_mcp.json

# Verify the tool was installed correctly
claude mcp list

方法2:通过UI手动配置

或者,您可以手动注册该工具:

  1. 在Claude Code中,导航到 设置→ 工具→ 管理MCP工具.
  2. 使用以下工具创建新工具:

- 名字: openai_codex - 描述: OpenAI Codex CLI integration via MCP server - 基本URL: http://localhost:8000/ - 协议: JSON-RPC 2.0 - 认证: _留空_

  1. 保存该工具。

现在,Claude Code可以将OpenAI Codex CLI工具用于需要不同视角或方法的任务。您可以通过让Claude为特定任务使用OpenAI模型来调用它。

API使用

MCP服务器为不同的编码任务提供了多种与OpenAI模型交互的方法。

方法1:总体竣工

对于OpenAI的灵活自定义提示:

curl -X POST http://localhost:8000/ \
     -H 'Content-Type: application/json' \
     -d '{
       "jsonrpc": "2.0",
       "method": "codex_completion",
       "params": {
         "prompt": "Write a JavaScript function to sort an array of objects by a property value",
         "model": "o4-mini"
       },
       "id": 1
     }'

方法2:编写代码

使用语言规范生成代码的专门方法:

curl -X POST http://localhost:8000/ \
     -H 'Content-Type: application/json' \
     -d '{
       "jsonrpc": "2.0",
       "method": "write_code",
       "params": {
         "task": "Calculate the first 100 Fibonacci numbers and return them as an array",
         "language": "python",
         "model": "o4-mini"
       },
       "id": 1
     }'

方法3:解释代码

代码解释的专门方法:

curl -X POST http://localhost:8000/ \
     -H 'Content-Type: application/json' \
     -d '{
       "jsonrpc": "2.0",
       "method": "explain_code",
       "params": {
         "code": "def quicksort(arr):\n    if len(arr)  pivot]\n    return quicksort(left) + middle + quicksort(right)",
         "model": "o4-mini"
       },
       "id": 1
     }'

方法4:调试代码

查找和修复错误的专门方法:

curl -X POST http://localhost:8000/ \
     -H 'Content-Type: application/json' \
     -d '{
       "jsonrpc": "2.0",
       "method": "debug_code",
       "params": {
         "code": "function fibonacci(n) {\n  if (n <= 0) return [];\n  if (n === 1) return [1];\n  let sequence = [1, 1];\n  for (let i = 2; i <= n; i++) {\n    sequence.push(sequence[i-2] + sequence[i-1]);\n  }\n  return sequence;\n}",
         "issue_description": "It generates one too many Fibonacci numbers",
         "model": "o4-mini"
       },
       "id": 1
     }'

可用型号

推理模型(O系列)

  • o4-mini:更快、更实惠的推理模型
  • o3:最强大的推理模型
  • o3-mini:o3的小型替代品
  • o1:以前的全o系列推理模型
  • o1-mini:o1的小型替代品
  • o1-pro:o1版本具有更多计算能力,可获得更好的响应

GPT模型

  • gpt-4.1:复杂任务的旗舰GPT模型
  • gpt-4o:快速、智能、灵活的GPT模型
  • gpt-4.1-mini:智能、速度和成本平衡
  • gpt-4.1-nano:最快、最具成本效益的GPT-4.1型号
  • gpt-4o-mini:用于集中任务的快速、经济实惠的小型模型

可用参数

全面竣工(代码x竣工)

  • prompt (必填):发送给食品法典委员会的提示
  • model (可选):要使用的型号(例如,“o4-mini”、“o3”、“gpt-4.1”、“gpt-4o-mini”)
  • images (可选):要包含的图像路径或数据URI列表
  • additional_args (可选):要传递给Codex的其他CLI参数

写代码(Write_Code)

  • task (必填):编码任务的描述
  • language (必填):解决方案的编程语言(例如“python”、“javascript”、“java”)
  • model (可选):要使用的模型

解释代码(Explain_Code)

  • code (必填):解释代码
  • model (可选):要使用的模型

调试代码(Debug_Code)

  • code (必填):要调试的代码
  • issue_description (可选):问题或错误的描述
  • model (可选):要使用的模型

使用Claude代码的示例用法

配置后,您可以要求Claude使用任何可用方法将OpenAI Codex用于特定任务:

使用write_code方法

User: Can you use OpenAI Codex to write a Python function that generates prime numbers?

Claude: I'll use the OpenAI Codex write_code method to generate that function.

[Claude would use the write_code method with task="Write a Python function that generates prime numbers" and language="python"]

使用explain_code方法

User: Can you ask OpenAI Codex to explain how this quicksort algorithm works?

Claude: I'll use OpenAI Codex to explain this algorithm.

[Claude would use the explain_code method with the code provided]

使用debug_code方法

User: My JavaScript function has a bug. Can you use OpenAI Codex to debug it?

Claude: I'll ask OpenAI Codex to find and fix the bug in your code.

[Claude would use the debug_code method with the code provided]

指定模型

User: Can you use OpenAI Codex with the o4-preview model to write an efficient implementation of a binary search tree?

Claude: I'll use the o4-preview model to generate that implementation.

[Claude would use the specified model with the appropriate method]

这允许您在同一个界面中无缝利用Claude和OpenAI的功能,并为常见的编码任务提供专门的方法。

目录标签

目录标签

代码生成PythonClaudedeveloper-toolsopenai-codexmcp-serverapi-wrapper本地部署代码解释代码调试JSON-RPCAI编程助手

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP