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(ios-simulator): disclose Xcode build access

JiangJiahaocb81dce7c264
diff --git a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts
index bbb2b767d3..a2af3ec7e9 100644
--- a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts
@@ -3,7 +3,9 @@ import { describe, expect, it } from 'vitest';
import {
getDesktopClaudeReadOnlyAllowedTools,
getDesktopMcpToolApprovalPolicy,
+ getDesktopMcpToolApprovalPresentation,
} from '../mcp-tool-approval-policy.js';
+import { setMainLocale } from '../../i18n.js';
describe('desktop Claude read-only allowlist', () => {
it('allows only explicitly reviewed read-only tools', () => {
@@ -145,6 +147,12 @@ describe('desktop MCP approval policy', () => {
}),
).toBe('prompt-each-time');
}
+ expect(
+ getDesktopMcpToolApprovalPolicy({
+ serverName: 'cindy_ios_simulator',
+ toolParams: { name: 'build_app', args: {} },
+ }),
+ ).toBe('prompt-each-time');
expect(
getDesktopMcpToolApprovalPolicy({
serverName: 'cindy_ios_simulator',
@@ -154,6 +162,35 @@ describe('desktop MCP approval policy', () => {
).toBe('auto-approve');
});
+ it('discloses host file access before an agent starts an Xcode build', () => {
+ setMainLocale('en');
+ expect(
+ getDesktopMcpToolApprovalPresentation({
+ serverName: 'cindy_ios_simulator',
+ toolName: 'call_tool',
+ toolParams: { name: 'build_app', args: {} },
+ }),
+ ).toEqual({
+ title: 'Allow Xcode to build this project?',
+ description: expect.stringMatching(
+ /macOS user.*outside the project.*returned to the Agent.*trust this project/i,
+ ),
+ });
+ expect(
+ getDesktopMcpToolApprovalPresentation({
+ serverName: 'cindy_ios_simulator',
+ toolName: 'call_tool',
+ toolParams: { name: 'tap', args: {} },
+ }),
+ ).toBeUndefined();
+ expect(
+ getDesktopMcpToolApprovalPresentation({
+ serverName: 'cindy_ios_simulator',
+ toolParams: { name: 'build_app', args: {} },
+ })?.description,
+ ).toContain('outside the project');
+ });
+
it('auto-approves read-only discovery entries even on untrusted servers', () => {
// server 整体不可信, 但列工具清单 / 查连接状态没有副作用。
expect(
diff --git a/apps/desktop/src/main/maker-host/index.ts b/apps/desktop/src/main/maker-host/index.ts
index e147dcdac0..617c0abbf1 100644
--- a/apps/desktop/src/main/maker-host/index.ts
+++ b/apps/desktop/src/main/maker-host/index.ts
@@ -213,6 +213,7 @@ import { broadcastOrcaWorkerChanged } from './orcaWorkerBroadcast.js';
import {
getDesktopClaudeReadOnlyAllowedTools,
getDesktopMcpToolApprovalPolicy,
+ getDesktopMcpToolApprovalPresentation,
} from './mcp-tool-approval-policy.js';
import { mapCodexAppServerModelsToCatalog } from './codex-model-discovery.js';
import { prepareSharedProjectSkillLinks } from './shared-global-skills.js';
@@ -813,6 +814,7 @@ export function getMaker(): Maker {
// 行时, Claude 只剩上面那份静态只读白名单, 可信第一方 server 的 call_tool
// (浏览器自动化等高频入口)会逐次弹窗, 与 Codex 侧的静默执行行为分叉。
getMcpToolApprovalPolicy: getDesktopMcpToolApprovalPolicy,
+ getMcpToolApprovalPresentation: getDesktopMcpToolApprovalPresentation,
// 模型清单 SSoT = 目录(providers.json,OSS 运行时真源 / bundled 兜底)。maker-core 的
// CLAUDE_MODELS 已删、availableModels 起始为空;host 从账号可选目录派生 cc 列表注入
// (含 claude 订阅模型 + XD 网关路由的 gpt / 国产 / gemini 等)。active catalog 已在 splash 期
@@ -1359,6 +1361,7 @@ export function getMaker(): Maker {
// 未知或高风险 action 逐次弹卡且禁止“本会话允许”。
// 详见 AgentDeps.getMcpToolApprovalPolicy。
getMcpToolApprovalPolicy: getDesktopMcpToolApprovalPolicy,
+ getMcpToolApprovalPresentation: getDesktopMcpToolApprovalPresentation,
// 远端 Codex (P2): 给 session 标 remoteHostId 的, CodexAgent 通过这个钩子拿
// 远端 transport — SSH 连接已有 ConnectionPool (remote-ssh feature 起的) 管,
// 这里包一层把 RemoteHost + SshDaemonTransport 装起来。
diff --git a/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts b/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts
index 33a68bd86a..49a220941e 100644
--- a/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts
+++ b/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts
@@ -17,9 +17,15 @@
* 4. 其余 —— 逐次弹窗(第三方 server、cindy_ssh、插件 ghost_call…)
*/
-import type { McpToolApprovalContext, McpToolApprovalPolicy } from '@cindy/maker-core';
+import type {
+ McpToolApprovalContext,
+ McpToolApprovalPolicy,
+ McpToolApprovalPresentation,
+} from '@cindy/maker-core';
import { canAutoApproveContactsMcpTool } from '@cindy/mcps';
+import { t } from '../i18n.js';
+
/**
* 精确到工具的只读放行表,键为 `<server>::<tool>`。
*
@@ -113,7 +119,10 @@ export function getDesktopMcpToolApprovalPolicy(
: 'prompt-each-time';
}
if (serverName === 'cindy_ios_simulator') {
- if (toolName === 'call_tool') {
+ // Some Codex app-server versions omit the outer tool name but retain the
+ // validated progressive payload. Preserve the inner action's stricter
+ // policy instead of falling back to a persistable generic server prompt.
+ if (toolName === 'call_tool' || toolName === undefined) {
const innerName =
toolParams && typeof toolParams === 'object'
? (toolParams as { name?: unknown }).name
@@ -131,3 +140,24 @@ export function getDesktopMcpToolApprovalPolicy(
}
return 'prompt';
}
+
+/**
+ * Host-owned security copy for progressive MCP actions whose outer
+ * `call_tool` description cannot explain the inner action's real authority.
+ */
+export function getDesktopMcpToolApprovalPresentation(
+ context: McpToolApprovalContext,
+): McpToolApprovalPresentation | undefined {
+ const innerName =
+ context.serverName === 'cindy_ios_simulator' &&
+ (context.toolName === 'call_tool' || context.toolName === undefined) &&
+ context.toolParams &&
+ typeof context.toolParams === 'object'
+ ? (context.toolParams as { name?: unknown }).name
+ : undefined;
+ if (innerName !== 'build_app') return undefined;
+ return {
+ title: t('rightSidebar.iosSimulator.buildApproval.title'),
+ description: t('rightSidebar.iosSimulator.buildApproval.description'),
+ };
+}
diff --git a/apps/desktop/src/main/maker-host/pi-host.ts b/apps/desktop/src/main/maker-host/pi-host.ts
index b5936a1e64..2200a098bc 100644
--- a/apps/desktop/src/main/maker-host/pi-host.ts
+++ b/apps/desktop/src/main/maker-host/pi-host.ts
@@ -43,7 +43,10 @@ import piSystemPrompt from './pi-system-prompt.md?raw';
import { createLogger } from '../logger.js';
import { readMemorySettings } from './memory-settings-store.js';
import { registerPiProxySession } from './pi-proxy-session-auth.js';
-import { getDesktopMcpToolApprovalPolicy } from './mcp-tool-approval-policy.js';
+import {
+ getDesktopMcpToolApprovalPolicy,
+ getDesktopMcpToolApprovalPresentation,
+} from './mcp-tool-approval-policy.js';
import { getRipgrepBinaryPath } from './runtime-configs.js';
const log = createLogger('pi-host');
@@ -373,6 +376,7 @@ export function buildPiAgent(opts: BuildPiAgentOpts): PiAgent | null {
// 与 Claude Code / Codex 同一份第一方 MCP 审批真源。Pi 之前没接,导致 orca 这类
// 可信 server 的工具落进 Auto-review 灰区被模型静默 block(详见 pi/index.ts 权限门)。
getMcpToolApprovalPolicy: getDesktopMcpToolApprovalPolicy,
+ getMcpToolApprovalPresentation: getDesktopMcpToolApprovalPresentation,
resolvePiAgentHome: () => path.join(app.getPath('userData'), 'pi-agent-home'),
preparePiExtraSpawnConfig: (providers, ctx) => getPiExtraSpawnConfig(providers, opts.logger, ctx),
registerPiProxySession,
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index dd69efdc90..0d804ce296 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -4460,6 +4460,10 @@
"title": "iOS Simulator",
"startPrompt": "Open the iOS Simulator for me.",
"description": "Inspect the Xcode environment and simulators available to this local session.",
+ "buildApproval": {
+ "title": "Allow Xcode to build this project?",
+ "description": "Xcode will run this project's build scripts as your macOS user. They may read or modify files outside the project, and build output is returned to the Agent. Continue only if you trust this project."
+ },
"refresh": "Refresh",
"checking": "Checking",
"accessRequiredTitle": "Authorize This Session",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 4e59c1a0bf..1b8ad46a0d 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -4458,6 +4458,10 @@
"title": "iOS シミュレータ",
"startPrompt": "iOS シミュレータを開いてください。",
"description": "このローカルセッションで使用できる Xcode 環境とシミュレータを確認します。",
+ "buildApproval": {
+ "title": "Xcode にこのプロジェクトのビルドを許可しますか?",
+ "description": "Xcode は macOS ユーザーの権限でこのプロジェクトのビルドスクリプトを実行します。スクリプトはプロジェクト外のファイルを読み取りまたは変更でき、ビルド出力は Agent に返されます。信頼できるプロジェクトの場合のみ続行してください。"
+ },
"refresh": "更新",
"checking": "確認中",
"accessRequiredTitle": "このセッションを承認",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 6d523fe922..9777ce7053 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -4458,6 +4458,10 @@
"title": "iOS 시뮬레이터",
"startPrompt": "iOS 시뮬레이터를 열어 주세요.",
"description": "이 로컬 세션에서 사용할 수 있는 Xcode 환경과 시뮬레이터를 확인합니다.",
+ "buildApproval": {
+ "title": "Xcode가 이 프로젝트를 빌드하도록 허용할까요?",
+ "description": "Xcode는 macOS 사용자 권한으로 이 프로젝트의 빌드 스크립트를 실행합니다. 스크립트는 프로젝트 외부의 파일을 읽거나 수정할 수 있고, 빌드 출력은 Agent에 반환됩니다. 신뢰하는 프로젝트인 경우에만 계속하세요."
+ },
"refresh": "새로 고침",
"checking": "확인 중",
"accessRequiredTitle": "이 세션 승인",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 0ba4077f09..b239cc5382 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -4458,6 +4458,10 @@
"title": "iOS 模拟器",
"startPrompt": "帮我打开 iOS 模拟器。",
"description": "查看当前本地任务可用的 Xcode 环境和模拟器设备。",
+ "buildApproval": {
+ "title": "允许 Xcode 构建此项目?",
+ "description": "Xcode 会以你的 macOS 用户权限运行此项目的构建脚本。这些脚本可能读取或修改项目外的文件,构建输出也会返回给 Agent。请仅在信任此项目时继续。"
+ },
"refresh": "刷新",
"checking": "正在检查",
"accessRequiredTitle": "授权当前任务",
diff --git a/packages/lizi-mcps/src/ios-simulator/tools.ts b/packages/lizi-mcps/src/ios-simulator/tools.ts
index 924f737605..bf2f4963b4 100644
--- a/packages/lizi-mcps/src/ios-simulator/tools.ts
+++ b/packages/lizi-mcps/src/ios-simulator/tools.ts
@@ -603,7 +603,7 @@ export function registerIOSSimulatorTools(
registry.register({
name: "build_app",
description:
- "Build one iOS app for the embedded simulator instance. For repositories with multiple or nested Xcode containers, pass containerPath as a worktree-relative path (or an absolute path that still resolves inside the worktree), then select a shared scheme when needed. Continue with install_app and launch_app on this same Cindy session. This may require command approval.",
+ "Build one iOS app for the embedded simulator instance. Xcode runs the project's build scripts as the current macOS user, so scripts may read or modify files outside the project and build output is returned to the Agent. Approve only for a trusted project. For repositories with multiple or nested Xcode containers, pass containerPath as a worktree-relative path (or an absolute path that still resolves inside the worktree), then select a shared scheme when needed. Continue with install_app and launch_app on this same Cindy session.",
inputShape: {
...routeShape,
containerPath: z.string().trim().min(1).max(4096).optional(),
diff --git a/packages/maker-core/src/agents/base-agent.ts b/packages/maker-core/src/agents/base-agent.ts
index bdda7db324..fab29d72b5 100644
--- a/packages/maker-core/src/agents/base-agent.ts
+++ b/packages/maker-core/src/agents/base-agent.ts
@@ -134,6 +134,12 @@ export type McpToolApprovalPolicy =
| 'prompt'
| 'prompt-each-time';
+/** Host-owned copy for an MCP permission request that needs a specific risk disclosure. */
+export interface McpToolApprovalPresentation {
+ title?: string;
+ description?: string;
+}
+
/** Pi 内 MCP client 的 server 描述;remote 存在时直接访问外部 Streamable HTTP MCP。 */
export interface PiMcpServerRef {
name: string;
@@ -661,6 +667,17 @@ export interface AgentDeps {
*/
getMcpToolApprovalPolicy?: (context: McpToolApprovalContext) => McpToolApprovalPolicy;
+ /**
+ * Optional host-owned title and description for an MCP approval card.
+ *
+ * This stays separate from the policy mode: a call can remain
+ * `prompt-each-time` while the Host explains a risk the generic MCP client
+ * cannot infer from the outer `call_tool` envelope.
+ */
+ getMcpToolApprovalPresentation?: (
+ context: McpToolApprovalContext,
+ ) => McpToolApprovalPresentation | undefined;
+
/**
* Codex-only deterministic tool activation for narrow host capabilities.
* Definitions are frozen at thread creation and restored handlers are gated
diff --git a/packages/maker-core/src/agents/claude-code/__tests__/mcp-approval-policy.test.ts b/packages/maker-core/src/agents/claude-code/__tests__/mcp-approval-policy.test.ts
index fb62d1f4ee..80cd1211e6 100644
--- a/packages/maker-core/src/agents/claude-code/__tests__/mcp-approval-policy.test.ts
+++ b/packages/maker-core/src/agents/claude-code/__tests__/mcp-approval-policy.test.ts
@@ -167,7 +167,12 @@ function createFakeQuery(
type CanUseToolFn = (
toolName: string,
input: Record<string, unknown>,
- options: { toolUseID: string; suggestions?: unknown[] },
+ options: {
+ toolUseID: string;
+ title?: string;
+ description?: string;
+ suggestions?: unknown[];
+ },
) => Promise<{
behavior: 'allow' | 'deny';
updatedInput?: Record<string, unknown>;
@@ -200,6 +205,7 @@ async function startSession(
scope?: string;
}>;
turnChangeCapture?: AgentDeps['turnChangeCapture'];
+ getMcpToolApprovalPresentation?: AgentDeps['getMcpToolApprovalPresentation'];
},
) {
const configDir = await makeTempDir();
@@ -216,6 +222,7 @@ async function startSession(
const deps = createDeps(policy, options?.mcpServerNames);
deps.capabilityRouting = options?.capabilityRouting;
deps.turnChangeCapture = options?.turnChangeCapture;
+ deps.getMcpToolApprovalPresentation = options?.getMcpToolApprovalPresentation;
const agent = new ClaudeCodeAgent(deps);
const handle = await agent.startSession({
sessionId: 'session-mcp-policy',
@@ -632,6 +639,38 @@ describe('ClaudeCodeAgent canUseTool honors the host MCP approval policy', () =>
await handle.close();
});
+ it('uses the host security disclosure for a progressive MCP action', async () => {
+ const disclosure = {
+ title: 'Allow Xcode to build this project?',
+ description:
+ 'Build scripts may access files outside the project, and output is returned to the Agent.',
+ };
+ const { handle, canUseTool, seen } = await startSession(() => 'prompt-each-time', {
+ mcpServerNames: ['cindy_ios_simulator'],
+ getMcpToolApprovalPresentation: () => disclosure,
+ });
+
+ await canUseTool(
+ 'mcp__cindy_ios_simulator__call_tool',
+ { name: 'build_app', args: {} },
+ {
+ toolUseID: 't-build',
+ title: 'Generic MCP approval',
+ description: 'Generic MCP description',
+ suggestions: SESSION_SUGGESTION,
+ },
+ );
+
+ expect(permissionRequests(seen)).toEqual([
+ expect.objectContaining({
+ title: disclosure.title,
+ description: disclosure.description,
+ suggestions: undefined,
+ }),
+ ]);
+ await handle.close();
+ });
+
it('falls back to prompt-each-time when the policy throws or returns garbage', async () => {
const thrower = await startSession(() => {
throw new Error('policy exploded');
@@ -996,6 +1035,7 @@ describe('remote sessions share the same permission semantics', () => {
initMcpServerNames?: readonly string[];
failedInitMcpServerNames?: readonly string[];
getGhostRosterPrompt?: AgentDeps['getGhostRosterPrompt'];
+ getMcpToolApprovalPresentation?: AgentDeps['getMcpToolApprovalPresentation'];
},
) {
const configDir = await makeTempDir();
@@ -1005,6 +1045,7 @@ describe('remote sessions share the same permission semantics', () => {
let onApprovalRequest: ((raw: unknown) => Promise<{ behavior?: string }>) | undefined;
const deps = createDeps(policy);
deps.getGhostRosterPrompt = options?.getGhostRosterPrompt;
+ deps.getMcpToolApprovalPresentation = options?.getMcpToolApprovalPresentation;
deps.capabilityRouting = options?.capabilityRouting;
// 远端只装得到 stdio / sse / http 类 server —— in-process 的会被 filter 掉。
deps.mcpProviders = (
@@ -1168,6 +1209,42 @@ describe('remote sessions share the same permission semantics', () => {
await handle.close();
});
+ it('uses the host security disclosure for remote progressive MCP actions', async () => {
+ const disclosure = {
+ title: 'Allow Xcode to build this project?',
+ description:
+ 'Build scripts may access files outside the project, and output is returned to the Agent.',
+ };
+ const { handle, onApprovalRequest, seen } = await startRemoteSession(
+ () => 'prompt-each-time',
+ {
+ mcpServerNames: ['cindy_ios_simulator'],
+ getMcpToolApprovalPresentation: () => disclosure,
+ attachResolver: () => ({ kind: 'permission', behavior: 'deny' }),
+ },
+ );
+
+ const result = await onApprovalRequest({
+ requestId: 'r-build',
+ kind: 'permission',
+ toolName: 'mcp__cindy_ios_simulator__call_tool',
+ input: { name: 'build_app', args: {} },
+ title: 'Generic MCP approval',
+ description: 'Generic MCP description',
+ suggestions: SESSION_SUGGESTION,
+ });
+
+ expect(result.behavior).toBe('deny');
+ expect(permissionRequests(seen)).toEqual([
+ expect.objectContaining({
+ title: disclosure.title,
+ description: disclosure.description,
+ suggestions: undefined,
+ }),
+ ]);
+ await handle.close();
+ });
+
it('fails closed instead of allowing when no resolver is attached', async () => {
const { handle, onApprovalRequest } = await startRemoteSession(() => 'prompt');
diff --git a/packages/maker-core/src/agents/claude-code/index.ts b/packages/maker-core/src/agents/claude-code/index.ts
index 0a8a6c06a6..3f3c7bc85e 100644
--- a/packages/maker-core/src/agents/claude-code/index.ts
+++ b/packages/maker-core/src/agents/claude-code/index.ts
@@ -1497,6 +1497,29 @@ export class ClaudeCodeAgent extends BaseAgent {
return 'prompt-each-time';
};
+ const mcpApprovalPresentation = (
+ toolName: string,
+ input: unknown,
+ ) => {
+ const presenter = this.deps.getMcpToolApprovalPresentation;
+ if (!presenter) return undefined;
+ const target = resolveMcpToolTarget(toolName, registeredMcpServerNames);
+ if (!target) return undefined;
+ try {
+ return presenter({
+ serverName: target.serverName,
+ toolName: target.toolName,
+ toolParams: input,
+ });
+ } catch (error) {
+ log.error('MCP approval presentation threw -> vendor copy', {
+ serverName: target.serverName,
+ error: error instanceof Error ? error.message : String(error),
+ });
+ return undefined;
+ }
+ };
+
// canUseTool dispatcher —— 三路分支(参考 agentManager.ts:1054-1162):
// 1. AskUserQuestion: 模型问问题, 转 ask_user_question kind, decision.answers 拼回 updatedInput
// 2. ExitPlanMode: plan 模式提交计划, 转 plan_review kind, decision.editedPlan 覆盖 plan
@@ -1645,6 +1668,7 @@ export class ClaudeCodeAgent extends BaseAgent {
// 3a. MCP 工具过 host 审批策略(本地与远端会话共用 classifyMcpApprovalPolicy)。
const turnPolicyForcePrompt = forceTurnConfirmation(toolName, input);
const mcpApprovalPolicy = classifyMcpApprovalPolicy(toolName, input);
+ const hostApprovalPresentation = mcpApprovalPresentation(toolName, input);
let forcePrompt = turnPolicyForcePrompt;
if (mutablePermissionMode === 'auto' && !toolName.startsWith('mcp__')) {
const workspaceRoots = [opts.workingDir, ...mutableExtraDirs].filter(
@@ -1692,9 +1716,9 @@ export class ClaudeCodeAgent extends BaseAgent {
requestId: options.toolUseID,
toolName,
input: input as Record<string, unknown>,
- title: options.title,
+ title: hostApprovalPresentation?.title ?? options.title,
displayName: options.displayName,
- description: options.description,
+ description: hostApprovalPresentation?.description ?? options.description,
// prompt-each-time 的语义是"每次都要人过目", 因此不把会话级 suggestion 交给
// UI —— 否则用户点一次"总是允许"就把逐次确认的高风险 action 永久放行了。
suggestions: forcePrompt
@@ -2651,6 +2675,10 @@ export class ClaudeCodeAgent extends BaseAgent {
params.input ?? {},
);
const remoteMcpPolicy = classifyMcpApprovalPolicy(remoteToolName, params.input ?? {});
+ const remoteHostApprovalPresentation = mcpApprovalPresentation(
+ remoteToolName,
+ params.input ?? {},
+ );
let remoteForcePrompt = remoteTurnPolicyForcePrompt;
if (
mutablePermissionMode === 'auto'
@@ -2688,9 +2716,9 @@ export class ClaudeCodeAgent extends BaseAgent {
requestId: params.requestId,
toolName: params.toolName ?? 'unknown',
input: params.input ?? {},
- title: params.title,
+ title: remoteHostApprovalPresentation?.title ?? params.title,
displayName: params.displayName,
- description: params.description,
+ description: remoteHostApprovalPresentation?.description ?? params.description,
suggestions: remoteForcePrompt
? undefined
: this.normalizeSessionPermissionSuggestions(params.suggestions),
diff --git a/packages/maker-core/src/agents/codex/index.test.ts b/packages/maker-core/src/agents/codex/index.test.ts
index fe533f3dbe..dee61b5632 100644
--- a/packages/maker-core/src/agents/codex/index.test.ts
+++ b/packages/maker-core/src/agents/codex/index.test.ts
@@ -10895,6 +10895,60 @@ describe('CodexAgent MCP thread context hooks', () => {
await handle.close();
});
+ it('uses the host security disclosure for progressive MCP approvals', async () => {
+ const disclosure = {
+ title: 'Allow Xcode to build this project?',
+ description:
+ 'Build scripts may access files outside the project, and output is returned to the Agent.',
+ };
+ const presentation = vi.fn(() => disclosure);
+ const agent = new CodexAgent(createDeps({}, {
+ getMcpToolApprovalPolicy: () => 'prompt-each-time',
+ getMcpToolApprovalPresentation: presentation,
+ }));
+ const host = installFakeHost(agent);
+ const handle = await agent.startSession({
+ sessionId: 'session-ios-build-disclosure',
+ model: 'gpt-5.4',
+ workingDir: '/repo',
+ permissionMode: 'ask',
+ });
+ const resolver = vi.fn(async () => ({
+ kind: 'permission' as const,
+ behavior: 'deny' as const,
+ }));
+ handle.setInteractionResolver(resolver);
+
+ const handlers = host.getThreadHandlers();
+ if (!handlers?.mcpServerElicitation) throw new Error('expected mcpServerElicitation handler');
+ const result = await handlers.mcpServerElicitation({
+ threadId: 'start-thread-id',
+ turnId: 'turn-ios-build',
+ serverName: 'cindy_ios_simulator',
+ mode: 'form',
+ _meta: {
+ codex_approval_kind: 'mcp_tool_call',
+ persist: ['session'],
+ tool_params: { name: 'build_app', args: {} },
+ },
+ message: 'Generic MCP approval',
+ requestedSchema: {},
+ });
+
+ expect(result).toEqual({ action: 'decline', content: null, _meta: null });
+ expect(resolver).toHaveBeenCalledWith(expect.objectContaining({
+ kind: 'permission',
+ title: disclosure.title,
+ description: disclosure.description,
+ suggestions: undefined,
+ }));
+ expect(presentation).toHaveBeenCalledWith({
+ serverName: 'cindy_ios_simulator',
+ toolParams: { name: 'build_app', args: {} },
+ });
+ await handle.close();
+ });
+
it('still prompts for prompt-each-time inner MCP calls in Full access mode', async () => {
// 回归:宽松档曾无条件 accept, 让高风险 inner tool(contacts_delete 等)
// 绕过逐次确认;Full access 也必须保留 forcePrompt 护栏。
@@ -12395,6 +12449,11 @@ describe('CodexAgent MCP thread context hooks', () => {
});
it('keeps host dynamic tool calls behind the existing MCP approval policy', async () => {
+ const disclosure = {
+ title: 'Allow Xcode to build this project?',
+ description:
+ 'Build scripts may access files outside the project, and output is returned to the Agent.',
+ };
const callTool = vi.fn(async () => ({
contentItems: [{ type: 'inputText' as const, text: '{"ok":true}' }],
success: true,
@@ -12411,6 +12470,7 @@ describe('CodexAgent MCP thread context hooks', () => {
callTool,
},
getMcpToolApprovalPolicy: () => 'prompt-each-time',
+ getMcpToolApprovalPresentation: () => disclosure,
}));
const host = installFakeHost(agent);
const handle = await agent.startSession({
@@ -12423,7 +12483,11 @@ describe('CodexAgent MCP thread context hooks', () => {
expect(request).toMatchObject({
kind: 'permission',
toolName: 'dynamic:cindy_ios_simulator:call_tool',
+ title: disclosure.title,
+ description: disclosure.description,
});
+ if (request.kind !== 'permission') throw new Error('expected permission request');
+ expect(request.suggestions).toBeUndefined();
return { kind: 'permission', behavior: 'deny' };
});
diff --git a/packages/maker-core/src/agents/codex/index.ts b/packages/maker-core/src/agents/codex/index.ts
index b10fb7dd09..6d8d0f1456 100644
--- a/packages/maker-core/src/agents/codex/index.ts
+++ b/packages/maker-core/src/agents/codex/index.ts
@@ -6055,6 +6055,22 @@ export class CodexAgent extends BaseAgent {
const mcpToolApprovalPolicy = (params: McpServerElicitationRequestParams) =>
classifyMcpToolApprovalPolicy(mcpToolApprovalContext(params));
+ const mcpToolApprovalPresentation = (
+ context: Parameters<NonNullable<AgentDeps['getMcpToolApprovalPolicy']>>[0],
+ ) => {
+ const presenter = this.deps.getMcpToolApprovalPresentation;
+ if (!presenter) return undefined;
+ try {
+ return presenter(context);
+ } catch (error) {
+ log.error('MCP approval presentation threw -> vendor copy', {
+ serverName: context.serverName,
+ error: error instanceof Error ? error.message : String(error),
+ });
+ return undefined;
+ }
+ };
+
const mcpServerElicitation = async (
params: McpServerElicitationRequestParams,
): Promise<McpServerElicitationRequestResponse> => {
@@ -6135,6 +6151,9 @@ export class CodexAgent extends BaseAgent {
// Host policy 可在 outer call_tool 的 metadata 中识别渐进式 server 的
// inner action。查询继续静默,高风险 action 逐次确认且不得持久化授权。
const approvalPolicy = mcpToolApprovalPolicy(params);
+ const hostApprovalPresentation = mcpToolApprovalPresentation(
+ mcpToolApprovalContext(params),
+ );
const policyPermissionInput = mcpElicitationPermissionInput(params);
const turnPolicyForcePrompt = forceTurnConfirmation(
`mcp:${params.serverName}`,
@@ -6164,8 +6183,10 @@ export class CodexAgent extends BaseAgent {
requestId,
toolName: `mcp:${params.serverName}`,
input: policyPermissionInput,
- title: `Allow Codex to use ${innerToolName ?? toolTitle ?? params.serverName}?`,
- description: params.message,
+ title:
+ hostApprovalPresentation?.title ??
+ `Allow Codex to use ${innerToolName ?? toolTitle ?? params.serverName}?`,
+ description: hostApprovalPresentation?.description ?? params.message,
suggestions:
approvalPolicy !== 'prompt-each-time' && mcpElicitationAllowsSession(params)
? codexSessionApprovalSuggestions()
@@ -6630,11 +6651,13 @@ export class CodexAgent extends BaseAgent {
}
const { serverName, toolName } = dynamicToolApprovalIdentity(params);
- const approvalPolicy = classifyMcpToolApprovalPolicy({
+ const approvalContext = {
serverName,
toolName,
toolParams: params.arguments,
- });
+ };
+ const approvalPolicy = classifyMcpToolApprovalPolicy(approvalContext);
+ const hostApprovalPresentation = mcpToolApprovalPresentation(approvalContext);
if (approvalPolicy !== 'auto-approve') {
const requestId = `dynamic-tool:${serverName}:${params.turnId}:${params.callId}`;
const decision = await awaitApprovalDecision(
@@ -6647,8 +6670,10 @@ export class CodexAgent extends BaseAgent {
requestId,
toolName: `dynamic:${serverName}:${toolName}`,
input: { serverName, toolName, toolParams: params.arguments },
- title: `Allow Codex to use ${serverName}?`,
- description: `Codex requested ${serverName}.${toolName}.`,
+ title: hostApprovalPresentation?.title ?? `Allow Codex to use ${serverName}?`,
+ description:
+ hostApprovalPresentation?.description ??
+ `Codex requested ${serverName}.${toolName}.`,
},
{ forcePrompt: approvalPolicy === 'prompt-each-time' },
);
diff --git a/packages/maker-core/src/agents/pi/__tests__/pi-auto-review-dispatch.test.ts b/packages/maker-core/src/agents/pi/__tests__/pi-auto-review-dispatch.test.ts
index 7b2d8cbd19..bb07c196e1 100644
--- a/packages/maker-core/src/agents/pi/__tests__/pi-auto-review-dispatch.test.ts
+++ b/packages/maker-core/src/agents/pi/__tests__/pi-auto-review-dispatch.test.ts
@@ -133,6 +133,7 @@ describe('pi auto-review dispatch & spawn config (mocked pi process)', () => {
/** 本会话「已注册」的桥接 MCP server 名(经 preparePiExtraSpawnConfig 下发)。 */
serverNames?: string[];
policy?: AgentDeps['getMcpToolApprovalPolicy'];
+ presentation?: AgentDeps['getMcpToolApprovalPresentation'];
}
function buildDeps(
@@ -142,6 +143,9 @@ describe('pi auto-review dispatch & spawn config (mocked pi process)', () => {
): AgentDeps {
return {
...(mcp?.policy ? { getMcpToolApprovalPolicy: mcp.policy } : {}),
+ ...(mcp?.presentation
+ ? { getMcpToolApprovalPresentation: mcp.presentation }
+ : {}),
...(mcp?.serverNames
? {
preparePiExtraSpawnConfig: async (_providers, context) => {
@@ -889,6 +893,37 @@ describe('pi auto-review dispatch & spawn config (mocked pi process)', () => {
expect(captured.sent).toContainEqual({ type: 'extension_ui_response', id: 'r21', confirmed: true });
});
+ it('uses the host security disclosure for progressive MCP approvals', async () => {
+ const disclosure = {
+ title: 'Allow Xcode to build this project?',
+ description:
+ 'Build scripts may access files outside the project, and output is returned to the Agent.',
+ };
+ const handle = await start('auto', undefined, false, {
+ serverNames: ['cindy_ios_simulator'],
+ policy: () => 'prompt-each-time',
+ presentation: () => disclosure,
+ });
+ const resolver = vi.fn(async () => ({ kind: 'permission', behavior: 'deny' } as const));
+ handle.setInteractionResolver?.(resolver as never);
+
+ firePermissionRequest('r-build', 'mcp__cindy_ios_simulator__call_tool', {
+ name: 'build_app',
+ args: {},
+ });
+
+ expect(await waitForResponse('r-build')).toEqual({
+ type: 'extension_ui_response',
+ id: 'r-build',
+ confirmed: false,
+ });
+ expect(resolver).toHaveBeenCalledWith(expect.objectContaining({
+ kind: 'permission',
+ title: disclosure.title,
+ description: disclosure.description,
+ }));
+ });
+
/**
* server 名可以含 `__`,盲切 `mcp__` 后首段会把第三方 `cindy_orca__evil` 认成第一方
* `cindy_orca` 并继承静默放行 —— 一条实打实的提权路径。归属判定取最长匹配。
diff --git a/packages/maker-core/src/agents/pi/index.ts b/packages/maker-core/src/agents/pi/index.ts
index 72d54986aa..9678eec22c 100644
--- a/packages/maker-core/src/agents/pi/index.ts
+++ b/packages/maker-core/src/agents/pi/index.ts
@@ -2517,6 +2517,24 @@ export class PiAgent extends BaseAgent {
return true;
}
})();
+ const mcpTarget = resolveMcpToolTarget(toolName, registeredMcpServerNames);
+ const hostApprovalPresentation = (() => {
+ const presenter = this.deps.getMcpToolApprovalPresentation;
+ if (!presenter || !mcpTarget) return undefined;
+ try {
+ return presenter({
+ serverName: mcpTarget.serverName,
+ toolName: mcpTarget.toolName,
+ toolParams: input,
+ });
+ } catch (err) {
+ this.deps.logger.error('MCP approval presentation threw -> generic copy', {
+ serverName: mcpTarget.serverName,
+ message: err instanceof Error ? err.message : String(err),
+ });
+ return undefined;
+ }
+ })();
/**
* 向用户要一次表态。`decided` 区分「用户明确表态」与「压根拿不到决策」(无 resolver /
* resolver 抛错 / kind 不匹配) —— 调用方对后者才允许按 Full access 语义放行,
@@ -2553,6 +2571,12 @@ export class PiAgent extends BaseAgent {
requestId: id,
toolName,
input,
+ ...(hostApprovalPresentation?.title
+ ? { title: hostApprovalPresentation.title }
+ : {}),
+ ...(hostApprovalPresentation?.description
+ ? { description: hostApprovalPresentation.description }
+ : {}),
})).then((decision) => {
if (decision.kind !== 'permission') {
this.deps.logger.warn('pi permission got mismatched decision kind', {
@@ -2629,24 +2653,23 @@ export class PiAgent extends BaseAgent {
const mcpPolicy = ((): 'auto-approve' | 'prompt' | 'prompt-each-time' | null => {
const classifier = this.deps.getMcpToolApprovalPolicy;
if (!classifier) return null;
- const target = resolveMcpToolTarget(toolName, registeredMcpServerNames);
- if (!target) return null;
+ if (!mcpTarget) return null;
try {
const policy = classifier({
- serverName: target.serverName,
- toolName: target.toolName,
+ serverName: mcpTarget.serverName,
+ toolName: mcpTarget.toolName,
toolParams: input,
});
if (policy === 'auto-approve' || policy === 'prompt' || policy === 'prompt-each-time') {
return policy;
}
this.deps.logger.error('invalid MCP approval policy -> user confirmation', {
- serverName: target.serverName,
+ serverName: mcpTarget.serverName,
policy,
});
} catch (err) {
this.deps.logger.error('MCP approval policy threw -> user confirmation', {
- serverName: target.serverName,
+ serverName: mcpTarget.serverName,
message: err instanceof Error ? err.message : String(err),
});
}