From aca7c799a804ad619d592f73e3a1f1666ba53794 Mon Sep 17 00:00:00 2001 From: bowei Date: Sat, 29 Aug 2026 04:54:44 +0800 Subject: [PATCH] =?UTF-8?q?tools-sync:=20MCP=20=E5=AE=A1=E8=AE=A1=E6=94=B9?= =?UTF-8?q?=E7=94=A8=20codex=20mcp=20list=20--json=20=E4=BD=9C=E4=B8=BA=20?= =?UTF-8?q?Codex=20=E4=BE=A7=E6=9D=83=E5=A8=81=E5=8F=A3=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codex 26.825 起不再把用户 MCP 注册写入 ~/.codex/config.toml,导致原来解析 config.toml 的审计每次都把 7 个已注册 MCP 误报成 "Claude only" 并重复 add。 - Get-CodexMcps 优先调用 `codex mcp list --json`,CLI 不可用时回落到原 TOML 解析 - cua_repl(Codex 自带 ChatGPT.exe 运行时,装在 WindowsApps 下,原 .codex/runtimes 正则匹配不到)纳入 Test-CodexManaged 自动排除,不再需要每次 -ExcludeName --- tools-sync/scripts/sync_mcp_registrations.ps1 | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools-sync/scripts/sync_mcp_registrations.ps1 b/tools-sync/scripts/sync_mcp_registrations.ps1 index e33ddde..0fc2389 100644 --- a/tools-sync/scripts/sync_mcp_registrations.ps1 +++ b/tools-sync/scripts/sync_mcp_registrations.ps1 @@ -105,7 +105,32 @@ function Get-ClaudeMcps { return $result } +function Get-CodexMcpsFromCli { + # Codex >= 26.8 no longer persists user MCP registrations in config.toml; + # `codex mcp list --json` is the authoritative view. Returns $null when the + # CLI is unavailable so the caller can fall back to TOML parsing. + $codexExe = Get-Command codex -ErrorAction SilentlyContinue + if (-not $codexExe) { return $null } + $raw = @(& $codexExe.Source mcp list --json 2>$null) + if ($LASTEXITCODE -ne 0 -or -not $raw) { return $null } + try { $servers = ($raw -join "`n") | ConvertFrom-Json } catch { return $null } + if ($null -eq $servers) { return $null } + $result = @{} + foreach ($s in @($servers)) { + $t = $s.transport + $transport = if ($t.type) { [string]$t.type } elseif ($t.url) { "http" } else { "stdio" } + if ($transport -eq "streamable_http") { $transport = "http" } + $result[[string]$s.name] = New-CanonicalMcp ([string]$s.name) $transport ([string]$t.command) ` + @($t.args) (ConvertTo-StringMap $t.env) ([string]$t.url) ` + (ConvertTo-StringMap $t.http_headers) ([string]$t.bearer_token_env_var) "Codex" + } + return $result +} + function Get-CodexMcps { + $fromCli = Get-CodexMcpsFromCli + if ($null -ne $fromCli) { return $fromCli } + if (-not (Test-Path -LiteralPath $CodexConfig)) { throw "Codex config not found: $CodexConfig" }