Skip to main content
Glama
AaAndrew233

ChatGPT Codex Bridge

by AaAndrew233

ChatGPT Codex Bridge

简体中文 | 安全 | 贡献指南

一个本地优先的 MCP 桥接器,让 ChatGPT 可以检查已注册的 Codex 项目、读取 Codex 会话历史,并将已确认的任务派发给本地 Codex CLI。

[!IMPORTANT] 这是一个独立的社区项目。它不是 OpenAI 的官方产品,与 OpenAI 无关联,也未获得 OpenAI 的认可。ChatGPT、Codex 和 OpenAI 均为其各自所有者的商标。

功能

  • 发现已在 Codex Desktop 中注册的项目,无需授予对整个主目录的访问权限。

  • 在 Codex 只读沙箱中运行分析和规划。

  • 在工作区写入前要求提供短期、一次性使用的确认令牌。

  • 以游标分页和脱敏方式列出并读取可见的 Codex 会话。

  • 构建有界项目历史上下文,而不会将数 GB 的历史记录加载到内存中。

  • 通过本地 Codex 应用服务器协议创建和继续持久化 Codex Desktop 会话。

  • 将 ChatGPT 提供的上下文作为不可信参考文本交给 Codex,并带有秘密检测。

  • 使用后台任务,使长时间运行的 Codex 任务不会占用 MCP 隧道请求。

该桥接器不暴露任意 shell 工具,也不监听公共端口。远程访问由官方 OpenAI Secure MCP Tunnel 客户端 提供。

架构

flowchart LR
    A[ChatGPT] -->|MCP connector| B[OpenAI Secure MCP Tunnel]
    B -->|outbound tunnel| C[tunnel-client on your machine]
    C -->|stdio MCP| D[ChatGPT Codex Bridge]
    D -->|sandboxed commands| E[Codex CLI]
    D -->|read-only indexes| F[Codex projects and sessions]
    D -. optional local IPC .-> G[Codex Desktop sidebar refresh]

可选的侧边栏刷新路径依赖于一个私有的、不受支持的 Codex Desktop 扩展,不包含在本仓库中。核心桥接器无需它即可工作;新建的持久化会话可能需要重启 Codex Desktop 后才会出现在侧边栏中。

环境要求

  • 装有 Python 3.11+ 的 macOS 或 Linux

  • 可用的 codex CLI 安装和登录

  • 用于自动项目发现和会话历史功能的 Codex Desktop

  • 用于文档所述 Tunnel 安装路径的 Homebrew

  • 具有 Secure MCP Tunnels 访问权限的 OpenAI 组织

本项目目前已在 macOS 上测试。不支持 Windows,因为可选的桌面通知路径使用 Unix 套接字。

快速开始

git clone https://github.com/AaAndrew233/chatgpt-codex-bridge.git
cd chatgpt-codex-bridge
./scripts/bootstrap.sh

bootstrap.sh 会创建本地虚拟环境,安装经过审查的依赖锁文件,并生成不受跟踪的 config.json.mcp.json 文件。它绝不会覆盖现有配置。

打开 config.json 并选择一种授权来源:

{
  "codex_command": "codex",
  "model": null,
  "codex_project_catalog": "~/.codex/.codex-global-state.json",
  "allowed_roots": []
}
  • model 保留为 null 以继承当前的 Codex 配置。

  • allowed_roots 留空,仅使用已在 Codex Desktop 中注册的项目。

  • 仅在自动发现不可用时,才将狭窄的项目目录添加到 allowed_roots

  • 切勿授权 / 或您的主目录。桥接器会拒绝这两者。

运行本地检查:

./scripts/check_public_release.py
.venv/bin/python -m unittest discover -s tests -v

通过 Secure MCP Tunnel 连接

安装官方客户端:

brew install openai/tools/tunnel-client
tunnel-client --version
tunnel-client help quickstart

将运行时密钥存储在本仓库之外的文件中,并限制其权限:

chmod 600 /ABSOLUTE/PATH/TO/runtime-key

创建托管的后台运行时。替换所有占位值:

tunnel-client runtimes connect \
  --alias codex-bridge \
  --profile codex-bridge \
  --tunnel-id '<YOUR_TUNNEL_ID>' \
  --runtime-api-key 'file:/ABSOLUTE/PATH/TO/runtime-key' \
  --mcp-command '/ABSOLUTE/PATH/TO/chatgpt-codex-bridge/scripts/run_server.sh'

验证托管运行时正在运行、健康且就绪:

tunnel-client runtimes status codex-bridge --json

然后在 ChatGPT 连接器设置 中创建或刷新连接器。官方 Tunnel 入门指南是组织角色、隧道 ID、运行时密钥和当前命令的权威来源:openai/tunnel-client/docs/onboarding.md

不要使用管理员密钥作为长期运行的运行时。不要提交运行时密钥、隧道 ID、生成的配置文件、config.json.mcp.json

在 ChatGPT 中进行首次测试

在启用连接器的情况下开始一个新的 ChatGPT 对话,并询问:

Call codex_status. Show only whether the bridge is healthy, the available tool names,
and the registered project names. Do not modify files.

然后测试一个只读任务:

Use codex_analyze on <PROJECT_PATH> to summarize the project structure and identify
the three highest-risk areas. Poll the job until it finishes and retrieve every output page.
Do not modify files.

对于写入操作,ChatGPT 必须首先调用 codex_prepare_apply,向您展示确切的计划,获得您的明确确认,然后才能使用返回的令牌调用 codex_apply

MCP 工具

工具

用途

写入确认

codex_status

健康状态、能力、项目、任务和兼容性快照

codex_list_projects

列出已授权的 Codex 项目

codex_prepare_project_context

构建有界、分页的项目历史上下文

codex_analyze

提交只读 Codex 任务

codex_plan

提交仅规划模式的 Codex 任务

codex_prepare_apply

为一次精确的写入请求签发短期令牌

codex_apply

提交工作区写入 Codex 任务

codex_job_status

轮询后台任务

codex_job_result

读取带输出分页的已完成结果

codex_cancel_job

取消排队中或运行中的任务

codex_list_sessions

列出带分页的可见 Codex 会话

codex_read_session

读取带脱敏的可见用户和助手消息

codex_create_desktop_session

创建持久化 Codex Desktop 会话

仅写入模式

codex_continue_desktop_session

继续持久化会话

仅写入模式

codex_handoff_chat_context

使用显式 ChatGPT 上下文创建会话

仅写入模式

安全模型

信任边界刻意保持狭窄:

  • 项目访问仅限于经过验证的 Codex 项目根目录或显式的狭窄根目录。

  • 敏感目录(如 .ssh.aws.gnupg.kube.configLibrary)在自动发现期间会被拒绝。

  • Codex 子进程接收最小化环境,并以显式沙箱模式运行。

  • 写入令牌会过期、一次性使用,并绑定到确切的项目和请求。

  • 会话输出在离开机器前会过滤为仅用户可见消息并进行脱敏。

  • 请求、输出、扫描、并发、保留和超时限制均有界。

  • ChatGPT 上下文被视为不可信输入,不能覆盖本地策略。

在将桥接器暴露给团队之前,请阅读 docs/security-model.md。漏洞报告应遵循 SECURITY.md

运行限制

默认限制记录在 config.example.json 中,并在启动时强制执行。重要默认值包括两个并发任务、30 分钟已完成任务保留期、120,000 字符请求上限、分页的 100,000 字符任务输出,以及项目历史的有界流式扫描。

scan_complete 表示配置的源扫描是否完成。context_complete 单独表示所有扫描文本是否都适合返回的上下文预算。扫描完成不等于无界导出。

开发

./scripts/bootstrap.sh
.venv/bin/python -m unittest discover -s tests -v
.venv/bin/python -m compileall -q \
  bridge_core.py conversation_catalog.py desktop_assignment.py \
  desktop_sessions.py project_context.py server.py

有关贡献规则,请参阅 CONTRIBUTING.md;有关模块边界,请参阅 docs/architecture.md

许可证

Apache License 2.0。请参阅 LICENSE

-
license - not tested
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • Search your AI chat history (ChatGPT, Claude, Codex) from any MCP client. Remote, private, read-only

  • A paid remote MCP for OpenAI Codex agent coordination MCP, built to return verdicts, receipts, usage

  • Give AI agents secure access to ZERNO project briefs, tasks, and context over remote MCP.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AaAndrew233/chatgpt-codex-bridge'

If you have feedback or need assistance with the MCP directory API, please join our Discord server