Skip to content

[feature] 新增 MCP server,把 codex-pro skill 能力暴露為 typed tools #16

Description

@kiki830621

Problem

Original text:
「這邊我在想要不要作一個plugin和mcp,讓claude可以容易呼叫codex」
— Source: 使用者於 2026-08-16 直接提出(/idd-issue invocation)

Plain language interpretation:讓 Claude 呼叫 Codex 的介面應該從「skill prose + bash」升級為「typed MCP tools」。

一句話先把「plugin」那半答掉:plugin 已經存在——本 repo 的 codex-pro v0.8.0 就是那個 plugin,9 個 skill 全部落地。所以本 issue 真正新增的是 MCP 層,兩者共存而非取代:plugin 繼續提供 skill 介面與 profile 治理,MCP 提供 typed tool 介面。

而 MCP 這半,README 兩處已經明文把它列為刻意未做

Marketplace metadata 讓同一份 Git snapshot 可被 Codex CLI/App 或 Claude Code 安裝;本版仍維持 single plugin,沒有新增 MCP server、hook 或 app。

本版不修正上述上游問題,也不新增 Linux/Windows producer、改寫 batch、品牌資產、MCP server 或 hook。

本 issue 把它從「明示延後」轉為「決定要做」。

Type

feature

Expected

codex-pro 內新增一個 MCP server,把現有 skill 能力暴露為 typed MCP tools(scope 已裁定為「高階」,非 thin codex_call wrapper)。

Tool surface(沿用 CLAUDE.md 既有四分類,不另立分類法)

現有分類 Skill 建議 MCP tool 屬性
Mutating producer codex-review codex_review 呼叫 Codex、寫 result file
Mutating producer codex-rescue codex_rescue 同上
Mutating producer codex-adversarial-review codex_adversarial_review 同上
Read-only consumer codex-status codex_status 純讀 .codex-pro/
Read-only consumer codex-result codex_result 純讀單一 result file
Read-only consumer codex-config codex_config 純讀 resolved profile
Read-only environment codex-setup codex_setup 環境檢查
Read-only consumer codex-cancel (待裁定) informational only,tool 化價值最低
Mutating exception codex-batch (待裁定) fan-out shell job control,與 MCP 單次 request/response 模型不合

三個 producer 是價值核心——它們才真正燒 Codex quota,也是參數契約最需要保證的地方。

為什麼 typed tool 比現行 skill prose 好

現行路徑是 SKILL.md(散文指令)→ Claude 讀懂 → 自己組 bash → 呼叫 codex-call。這代表以下邏輯全部靠 Claude 照著散文做對

  • profile resolve(global ~/.codex-pro/profile.yaml + project .codex-pro/profile.yaml 兩層 merge、per-field 優先序)
  • diff 收集(git diff HEAD + untracked enumeration + binary path-only + per-file 64KB / aggregate 512KB size cap)
  • fail-fast 四類(rate_limit / oauth_invalid / timeout / target_invalid
  • result file 結構(frontmatter 欄位、必要 H2 heading)

其中至少兩項已經有踩過的實績:#1 是 Codex 輸出 heading 漂移、#6 是 producer skill 在 claude --print 下自行背景化導致 result file 孤兒。散文約束的失效方式是安靜的;typed tool 的 schema 由 server 驗證,參數錯誤是 loud failure。

關鍵設計約束(實作期必守)

  1. 不得 spawn codex-call 當 subprocess — 那會直接違反 codex-pro Design constraint review/adversarial-review Step 3 system-instruction hardening — required H2 headings unreliable in Codex output #1(「No subprocess spawn for Codex — 一律走 codex-call HTTPS direct」,防上游 #330 IPC deadlock)。MCP server 應吃下 codex-call 的 HTTPS 邏輯,而非包裝它。
  2. profile 契約不可分岔references/defaults.jsonreferences/profile-contract.md 是 EXTERNAL-CONSUMER CONTRACT(feat: officialize EXTERNAL-CONSUMER CONTRACT — profile-contract.md + machine-readable defaults.json (consumer: issue-driven-dev) #7)。MCP server 必須讀同一份 source of truth,不得複製第三份 hardcoded default。
  3. Skill 與 MCP 不得語意分歧 — 同一個 codex_review 從 skill 走或從 tool 走,profile resolve、size cap、fail-fast 分類必須產出相同結果。

Actual

  • 樹內沒有任何 .mcp.json,沒有 MCP server。
  • 全部 9 個 skill 都是 SKILL.md 散文 → Claude 組 bash → 呼叫 PATH 上的 codex-call
  • codex-call#!/usr/bin/swift script,住在 parallel-ai-agents plugin cache(v2.20.0);它自己讀 ~/.codex/auth.json、在 token 剩 5 分鐘內自動 refresh、並用 file lock 防並發 refresh 競態。
  • 其 flag surface:--output / --model / --effort / --service-tier / --max-time / --instructions / --prompt-file

Impact

#15 的耦合(必須一起裁定,否則會做兩次)

#15 正在推「codex-call executable 歸位到 codex-pro、依賴方向收斂為單向」。本 issue 的約束 1(MCP server 吃下 HTTPS 邏輯、不 spawn)本身就是 #15 的一條實作路徑:Swift MCP server 內含 HTTPS 呼叫,等於 executable 已經在 codex-pro 樹內。

兩者的先後順序會實質改變工作量:

建議在 /idd-diagnose 階段一併裁定順序。

既有基礎設施可直接沿用

  • Swift MCP server 的 sign / notarize pipeline 已建立且驗證可用(che-mcps-notary keychain profile,見全域 CLAUDE.md)。macOS 26 TCC 下 ad-hoc signed binary 無法正常取得授權,這條 pipeline 是對外分發的必經路徑。
  • codex-call 本身就是 Swift,語言一致,邏輯可直接吸收而非改寫。

待裁定(留給 diagnose)

Next

/issue-driven-dev:idd-diagnose #NNN


Clarity Surface(idd-clarify run 2026-08-16T04:42:02Z)

Type Source Question for you Status
ambiguity "MCP server 應吃下 codex-call 的 HTTPS 邏輯,而非包裝它" 「吃下」是指把 codex-call 的 Swift 原始碼搬進 codex-pro 樹內、重寫一份、還是讓它變成 Swift package dependency?這三種對 #15 的「歸位」算不算數不一樣。 resolved @ 2026-08-16T05:16:23Z (reason: 採 vendor:codex-call Swift 原始碼收進 codex-pro 樹內成為 MCP server 一部分;v0.8.0 已在分發帶 SHA-256 provenance 的 snapshot,順現有方向且 #15 直接達成)
ambiguity "codex-setupcodex_setup(Read-only environment)" MCP server 自己發 HTTPS 之後,codex_setup 還要檢查「codex-call 在 PATH」嗎?如果不用,那它剩下要檢查什麼? resolved @ 2026-08-16T05:16:23Z (reason: 改檢 OAuth token 有效性 + server 自身健康,不再檢查 codex-call 在 PATH)
missing-context "它自己讀 ~/.codex/auth.json、在 token 剩 5 分鐘內自動 refresh、並用 file lock 防並發 refresh 競態" MCP server 是 long-lived process,會跟 pai ensemble 仍在跑的 codex-call 同時碰同一個 token store——這個並發邊界要怎麼處理?沿用同一把 file lock 夠嗎? resolved @ 2026-08-16T05:16:23Z (reason: 沿用 codex-call 既有的同一把 file lock(相同 lock 檔路徑),跨 process 相容,改動最小)
missing-context "呼叫 Codex、寫 result file" MCP server 由 client spawn、cwd 未必是使用者的 project root,那 producer tool 的 .codex-pro/<skill>-<ts>.md 要寫到哪裡?由 tool 參數帶 project root 進來嗎? resolved @ 2026-08-16T05:16:23Z (reason: tool 參數顯式帶 project_root,schema 可驗證,與現行 skill 寫進 repo 內 .codex-pro/ 的行為一致)

Current Status

Phase: diagnosed
Last updated: 2026-08-16 by idd-diagnose

Key Decisions

  • 前提修正codex-call 已於本地 v0.8.0 vendored 進樹(bin/ + .codex/bin/ + plugins/codex-pro/runtime/ 三份 byte-identical + provenance),真正工作是執行模型轉換而非搬檔案
  • Clarity 裁決 1:採 vendor 原始碼進樹內(既成事實,順現有方向)
  • Clarity 裁決 2:codex_setup 改檢 OAuth 有效性 + server 健康,移除 PATH 檢查
  • Clarity 裁決 3:token 並發沿用 ~/.codex/.token-refresh.lock 同一把 file lock
  • Clarity 裁決 4:producer tool 以顯式 project_root 參數決定 result file 位置
  • Complexity = Spectra(Layer 2 命中:MCP tool surface 是對外 published protocol,已有外部 consumer 在 pin 契約;Layer 3 命中 2/3)
  • Conflict Class = C_shared_module_coord(共享資源:vendored codex-call snapshot 三份 bundle 複本,由 scripts/generate-codex-skills.sh 同步)

Scope Changes

Blocking

  • 本地 main 領先 origin/main 6 個未推送 commit((#10) 系列),remote 讀者看到的仍是舊拓撲 — 待處置(S1)
  • Spectra tier:需先走 /spectra-discuss 對齊方向,才進 /spectra-propose

Commits

  • (none yet)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions