From 2e57989aec569055a11f21762f72b961377281ab Mon Sep 17 00:00:00 2001 From: Olcan Date: Fri, 30 May 2025 15:32:21 -0700 Subject: confirm mcp tool executions from untrusted servers (per "trust" setting) (#631) --- .../messages/ToolConfirmationMessage.tsx | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'packages/cli/src/ui/components/messages/ToolConfirmationMessage.tsx') diff --git a/packages/cli/src/ui/components/messages/ToolConfirmationMessage.tsx b/packages/cli/src/ui/components/messages/ToolConfirmationMessage.tsx index 0606856f..65030309 100644 --- a/packages/cli/src/ui/components/messages/ToolConfirmationMessage.tsx +++ b/packages/cli/src/ui/components/messages/ToolConfirmationMessage.tsx @@ -12,6 +12,7 @@ import { ToolCallConfirmationDetails, ToolConfirmationOutcome, ToolExecuteConfirmationDetails, + ToolMcpConfirmationDetails, } from '@gemini-code/server'; import { RadioButtonSelect, @@ -64,7 +65,7 @@ export const ToolConfirmationMessage: React.FC< }, { label: 'No (esc)', value: ToolConfirmationOutcome.Cancel }, ); - } else { + } else if (confirmationDetails.type === 'exec') { const executionProps = confirmationDetails as ToolExecuteConfirmationDetails; @@ -88,6 +89,33 @@ export const ToolConfirmationMessage: React.FC< }, { label: 'No (esc)', value: ToolConfirmationOutcome.Cancel }, ); + } else { + // mcp tool confirmation + const mcpProps = confirmationDetails as ToolMcpConfirmationDetails; + + bodyContent = ( + + MCP Server: {mcpProps.serverName} + Tool: {mcpProps.toolName} + + ); + + question = `Allow execution of MCP tool "${mcpProps.toolName}" from server "${mcpProps.serverName}"?`; + options.push( + { + label: 'Yes, allow once', + value: ToolConfirmationOutcome.ProceedOnce, + }, + { + label: `Yes, always allow tool "${mcpProps.toolName}" from server "${mcpProps.serverName}"`, + value: ToolConfirmationOutcome.ProceedAlwaysTool, // Cast until types are updated + }, + { + label: `Yes, always allow all tools from server "${mcpProps.serverName}"`, + value: ToolConfirmationOutcome.ProceedAlwaysServer, + }, + { label: 'No (esc)', value: ToolConfirmationOutcome.Cancel }, + ); } return ( -- cgit v1.2.3