diff --git a/src/core/Cline.ts b/src/core/Cline.ts index ff016906e3..e8d34262df 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -2489,14 +2489,12 @@ export class Cline { arguments: mcp_arguments, } satisfies ClineAskUseMcpServer) - const isToolAlwaysAllowed = this.providerRef + const isToolAutoApproved = this.providerRef .deref() ?.mcpHub?.connections?.find((conn) => conn.server.name === server_name) - ?.server.tools?.find((tool) => tool.name === tool_name)?.alwaysAllow + ?.server.tools?.find((tool) => tool.name === tool_name)?.autoApprove - // console.log("isToolAlwaysAllowed", server_name, tool_name, isToolAlwaysAllowed) - - if (this.shouldAutoApproveTool(block.name) && isToolAlwaysAllowed) { + if (this.shouldAutoApproveTool(block.name) && isToolAutoApproved) { this.removeLastPartialMessageIfExistsWithType("ask", "use_mcp_server") await this.say("use_mcp_server", completeMessage, undefined, false) this.consecutiveAutoApprovedRequestsCount++ diff --git a/src/core/prompts/system.ts b/src/core/prompts/system.ts index cf2b3d1c62..0a5b66b875 100644 --- a/src/core/prompts/system.ts +++ b/src/core/prompts/system.ts @@ -717,7 +717,7 @@ npm run build 5. Install the MCP Server by adding the MCP server configuration to the settings file located at '${await mcpHub.getMcpSettingsFilePath()}'. The settings file may have other MCP servers already configured, so you would read it first and then add your new server to the existing \`mcpServers\` object. -IMPORTANT: Regardless of what else you see in the MCP settings file, you must default any new MCP servers you create to disabled=false and alwaysAllow=[]. +IMPORTANT: Regardless of what else you see in the MCP settings file, you must default any new MCP servers you create to disabled=false and autoApprove=[]. \`\`\`json { diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index 18fcd34ddf..111d71caab 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -616,9 +616,9 @@ export class ClineProvider implements vscode.WebviewViewProvider { } break } - case "toggleToolAlwaysAllow": { + case "toggleToolAutoApprove": { try { - await this.mcpHub?.toggleToolAlwaysAllow(message.serverName!, message.toolName!, message.alwaysAllow!) + await this.mcpHub?.toggleToolAutoApprove(message.serverName!, message.toolName!, message.autoApprove!) } catch (error) { console.error(`Failed to toggle auto-approve for tool ${message.toolName}:`, error) } diff --git a/src/services/mcp/McpHub.ts b/src/services/mcp/McpHub.ts index f3f5420192..2ea31b830d 100644 --- a/src/services/mcp/McpHub.ts +++ b/src/services/mcp/McpHub.ts @@ -25,14 +25,14 @@ export type McpConnection = { transport: StdioClientTransport } -const AlwaysAllowSchema = z.array(z.string()).default([]) +const AutoApproveSchema = z.array(z.string()).default([]) // StdioServerParameters const StdioConfigSchema = z.object({ command: z.string(), args: z.array(z.string()).optional(), env: z.record(z.string()).optional(), - alwaysAllow: AlwaysAllowSchema.optional(), + autoApprove: AutoApproveSchema.optional(), disabled: z.boolean().optional(), }) @@ -283,16 +283,16 @@ export class McpHub { .find((conn) => conn.server.name === serverName) ?.client.request({ method: "tools/list" }, ListToolsResultSchema) - // Get always allow settings + // Get autoApprove settings const settingsPath = await this.getMcpSettingsFilePath() const content = await fs.readFile(settingsPath, "utf-8") const config = JSON.parse(content) - const alwaysAllowConfig = config.mcpServers[serverName]?.alwaysAllow || [] + const autoApproveConfig = config.mcpServers[serverName]?.autoApprove || [] // Mark tools as always allowed based on settings const tools = (response?.tools || []).map((tool) => ({ ...tool, - alwaysAllow: alwaysAllowConfig.includes(tool.name), + autoApprove: autoApproveConfig.includes(tool.name), })) // console.log(`[MCP] Fetched tools for ${serverName}:`, tools) @@ -496,8 +496,8 @@ export class McpHub { } // Ensure required fields exist - if (!serverConfig.alwaysAllow) { - serverConfig.alwaysAllow = [] + if (!serverConfig.autoApprove) { + serverConfig.autoApprove = [] } config.mcpServers[serverName] = serverConfig @@ -582,26 +582,26 @@ export class McpHub { ) } - async toggleToolAlwaysAllow(serverName: string, toolName: string, shouldAllow: boolean): Promise { + async toggleToolAutoApprove(serverName: string, toolName: string, shouldAllow: boolean): Promise { try { const settingsPath = await this.getMcpSettingsFilePath() const content = await fs.readFile(settingsPath, "utf-8") const config = JSON.parse(content) - // Initialize alwaysAllow if it doesn't exist - if (!config.mcpServers[serverName].alwaysAllow) { - config.mcpServers[serverName].alwaysAllow = [] + // Initialize autoApprove if it doesn't exist + if (!config.mcpServers[serverName].autoApprove) { + config.mcpServers[serverName].autoApprove = [] } - const alwaysAllow = config.mcpServers[serverName].alwaysAllow - const toolIndex = alwaysAllow.indexOf(toolName) + const autoApprove = config.mcpServers[serverName].autoApprove + const toolIndex = autoApprove.indexOf(toolName) if (shouldAllow && toolIndex === -1) { - // Add tool to always allow list - alwaysAllow.push(toolName) + // Add tool to autoApprove list + autoApprove.push(toolName) } else if (!shouldAllow && toolIndex !== -1) { - // Remove tool from always allow list - alwaysAllow.splice(toolIndex, 1) + // Remove tool from autoApprove list + autoApprove.splice(toolIndex, 1) } // Write updated config back to file @@ -614,8 +614,8 @@ export class McpHub { await this.notifyWebviewOfServerChanges() } } catch (error) { - console.error("Failed to update always allow settings:", error) - vscode.window.showErrorMessage("Failed to update always allow settings") + console.error("Failed to update autoApprove settings:", error) + vscode.window.showErrorMessage("Failed to update autoApprove settings") throw error // Re-throw to ensure the error is properly handled } } diff --git a/src/shared/WebviewMessage.ts b/src/shared/WebviewMessage.ts index 5eb54169d5..50ae6ad8fd 100644 --- a/src/shared/WebviewMessage.ts +++ b/src/shared/WebviewMessage.ts @@ -35,7 +35,7 @@ export interface WebviewMessage { | "taskCompletionViewChanges" | "openAdvisorModelSettings" | "requestVsCodeLmModels" - | "toggleToolAlwaysAllow" + | "toggleToolAutoApprove" | "toggleMcpServer" // | "relaunchChromeDebugMode" text?: string @@ -52,7 +52,7 @@ export interface WebviewMessage { // For toggleToolAutoApprove serverName?: string toolName?: string - alwaysAllow?: boolean + autoApprove?: boolean } export type ClineAskResponse = "yesButtonClicked" | "noButtonClicked" | "messageResponse" diff --git a/src/shared/mcp.ts b/src/shared/mcp.ts index 7df1415cf4..b84f33d21a 100644 --- a/src/shared/mcp.ts +++ b/src/shared/mcp.ts @@ -13,7 +13,7 @@ export type McpTool = { name: string description?: string inputSchema?: object - alwaysAllow?: boolean + autoApprove?: boolean } export type McpResource = { diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index 8034142459..bc26bb152b 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -718,8 +718,8 @@ export const ChatRowContent = ({ message, isExpanded, onToggleExpand, lastModifi name: useMcpServer.toolName || "", description: server?.tools?.find((tool) => tool.name === useMcpServer.toolName)?.description || "", - alwaysAllow: - server?.tools?.find((tool) => tool.name === useMcpServer.toolName)?.alwaysAllow || + autoApprove: + server?.tools?.find((tool) => tool.name === useMcpServer.toolName)?.autoApprove || false, }} serverName={useMcpServer.serverName} diff --git a/webview-ui/src/components/mcp/McpToolRow.tsx b/webview-ui/src/components/mcp/McpToolRow.tsx index def6a36160..18619fe07f 100644 --- a/webview-ui/src/components/mcp/McpToolRow.tsx +++ b/webview-ui/src/components/mcp/McpToolRow.tsx @@ -11,14 +11,14 @@ type McpToolRowProps = { const McpToolRow = ({ tool, serverName }: McpToolRowProps) => { const { autoApprovalSettings } = useExtensionState() - const handleAlwaysAllowChange = () => { + const handleAutoApproveChange = () => { if (!serverName) return vscode.postMessage({ - type: "toggleToolAlwaysAllow", + type: "toggleToolAutoApprove", serverName, toolName: tool.name, - alwaysAllow: !tool.alwaysAllow, + autoApprove: !tool.autoApprove, }) } return ( @@ -36,8 +36,8 @@ const McpToolRow = ({ tool, serverName }: McpToolRowProps) => { {tool.name} {serverName && autoApprovalSettings.enabled && autoApprovalSettings.actions.useMcp && ( - - Always allow + + Auto-approve )}