Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(review): skip builtin Codex Apps MCP override

Chris33bb09520ad1
diff --git a/packages/maker-core/src/agents/codex/index.test.ts b/packages/maker-core/src/agents/codex/index.test.ts
index ebd35eed81..48fb6d1599 100644
--- a/packages/maker-core/src/agents/codex/index.test.ts
+++ b/packages/maker-core/src/agents/codex/index.test.ts
@@ -547,7 +547,13 @@ describe('CodexAgent permissions', () => {
};
}
if (method === Method.McpServerStatusList) {
- return { data: [{ name: 'runtime-mcp', tools: {} }], nextCursor: null };
+ return {
+ data: [
+ { name: 'codex_apps', tools: {} },
+ { name: 'local_docs', tools: {} },
+ ],
+ nextCursor: null,
+ };
}
if (method === Method.TurnStart) return { turn: { id: 'turn-review' } };
return undefined;
@@ -596,7 +602,6 @@ describe('CodexAgent permissions', () => {
'features.multi_agent': false,
'features.remote_plugin': false,
'mcp_servers.local_docs.enabled': false,
- 'mcp_servers.runtime-mcp.enabled': false,
'plugins."unsafe-plugin@personal".enabled': false,
'plugins."configured@personal".enabled': false,
'plugins."configured@personal".mcp_servers.configured_server.enabled': false,
@@ -631,6 +636,7 @@ describe('CodexAgent permissions', () => {
},
]);
expect(threadStart.config).not.toHaveProperty('mcp_servers.should_not_exist');
+ expect(threadStart.config).not.toHaveProperty('mcp_servers.codex_apps.enabled');
expect(handle.getPlanMode?.()).toBe(false);
await expect(
@@ -699,6 +705,36 @@ describe('CodexAgent permissions', () => {
await handle.close();
});
+ it('fails closed when Review sees an unknown runtime-only MCP server', async () => {
+ const reviewDir = await fs.mkdtemp(path.join(os.tmpdir(), 'codex-review-runtime-mcp-'));
+ tempRoots.push(reviewDir);
+ const agent = new CodexAgent(createDeps());
+ installFakeHost(
+ agent,
+ (method) => {
+ if (method === Method.ExperimentalFeatureEnablementSet) return {};
+ if (method === Method.ConfigRead) return { config: {} };
+ if (method === Method.McpServerStatusList) {
+ return {
+ data: [{ name: 'unknown_runtime_mcp', tools: {} }],
+ nextCursor: null,
+ };
+ }
+ return undefined;
+ },
+ { userAgent: 'mock-codex/0.145.0' },
+ );
+
+ await expect(
+ agent.startSession({
+ sessionId: 'session-review-runtime-mcp',
+ model: 'gpt-5.5',
+ workingDir: reviewDir,
+ reviewMode: true,
+ }),
+ ).rejects.toThrow(/runtime MCP servers without transport-bearing config: unknown_runtime_mcp/);
+ });
+
it('refuses to start Review when Codex native memory cannot be disabled', async () => {
const reviewDir = await fs.mkdtemp(path.join(os.tmpdir(), 'codex-review-memory-'));
tempRoots.push(reviewDir);
diff --git a/packages/maker-core/src/agents/codex/index.ts b/packages/maker-core/src/agents/codex/index.ts
index 7145e0f53d..3d8b56c281 100644
--- a/packages/maker-core/src/agents/codex/index.ts
+++ b/packages/maker-core/src/agents/codex/index.ts
@@ -449,6 +449,8 @@ function isLocalForkHostKey(key: string): boolean {
/** Review threads use a one-session app-server so native Codex memory cannot leak in. */
const LOCAL_REVIEW_HOST_PREFIX = 'local-review:';
+/** Codex Desktop's built-in Apps server has no user-configurable MCP transport. */
+const CODEX_APPS_MCP_SERVER_NAME = 'codex_apps';
function localReviewHostKey(sessionId: string): string {
return `${LOCAL_REVIEW_HOST_PREFIX}${sessionId || randomUUID()}`;
@@ -3848,7 +3850,8 @@ export class CodexAgent extends BaseAgent {
const effectiveConfig = asRecord(configResponse.config);
const configuredMcp = asRecord(effectiveConfig.mcp_servers);
const configuredPlugins = asRecord(effectiveConfig.plugins);
- const mcpServerNames = new Set(Object.keys(configuredMcp));
+ const configuredMcpServerNames = new Set(Object.keys(configuredMcp));
+ const unconfiguredRuntimeMcpServerNames = new Set<string>();
let cursor: string | null = null;
do {
const status: CodexMcpServerStatusListResponse =
@@ -3857,9 +3860,23 @@ export class CodexAgent extends BaseAgent {
{ cursor, limit: 100, detail: 'toolsAndAuthOnly', threadId: null },
{ timeoutMs: CRITICAL_THREAD_RPC_TIMEOUT_MS },
);
- for (const server of status.data) mcpServerNames.add(server.name);
+ for (const server of status.data) {
+ if (
+ !configuredMcpServerNames.has(server.name) &&
+ server.name !== CODEX_APPS_MCP_SERVER_NAME
+ ) {
+ unconfiguredRuntimeMcpServerNames.add(server.name);
+ }
+ }
cursor = status.nextCursor;
} while (cursor !== null);
+ if (unconfiguredRuntimeMcpServerNames.size > 0) {
+ throw new Error(
+ `Codex reported runtime MCP servers without transport-bearing config: ${[
+ ...unconfiguredRuntimeMcpServerNames,
+ ].sort().join(', ')}`,
+ );
+ }
const skillPaths = new Set([
...skills.map((skill) => skill.path),
@@ -3877,7 +3894,13 @@ export class CodexAgent extends BaseAgent {
.sort()
.map((skillPath) => ({ path: skillPath, enabled: false }));
}
- for (const serverName of mcpServerNames) {
+ // Only configured MCP entries have a command/url transport that can
+ // accept a per-thread `.enabled=false` merge. `codex_apps` is an
+ // app-server builtin surfaced by mcpServerStatus/list but absent from
+ // config/read; synthesizing an override for it makes Codex 0.145.0
+ // reject thread/start with "invalid transport". Apps are isolated by
+ // `features.apps=false` below instead.
+ for (const serverName of configuredMcpServerNames) {
reviewCapabilityConfig[
`mcp_servers.${renderReviewConfigSegment(serverName)}.enabled`
] = false;