confirm_action
Request user confirmation for actions with significant impact. Provide clear descriptions of the action, its potential effects, and additional details to ensure informed decision-making.
Instructions
Ask user to confirm an action before proceeding with potentially impactful operations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Description of the action to be confirmed | |
| details | No | Additional details about what will happen | |
| impact | No | Potential impact or consequences of this action |
Implementation Reference
- src/index.ts:689-754 (handler)The primary handler function for the 'confirm_action' tool. It extracts parameters, builds an elicitation message and schema for user confirmation, sends the request via sendElicitationRequest, and formats the response based on user input.private async handleConfirmAction(args: Record<string, unknown>) { const action = typeof args.action === "string" ? args.action : "Unknown action"; const impact = typeof args.impact === "string" ? args.impact : undefined; const details = typeof args.details === "string" ? args.details : undefined; let message = `Please confirm this action:\n\n**Action**: ${action}`; if (impact) { message += `\n\n**Impact**: ${impact}`; } if (details) { message += `\n\n**Details**: ${details}`; } message += `\n\nDo you want to proceed?`; const elicitationParams: ElicitationParams = { message, requestedSchema: { type: "object", properties: { confirmed: { type: "boolean", title: "Confirm Action", description: "Do you want to proceed with this action?", }, note: { type: "string", title: "Additional Note", description: "Any additional instructions or concerns?", }, }, required: ["confirmed"], }, timeoutMs: this.determineTimeoutForAction(impact), }; try { const response = await this.sendElicitationRequest(elicitationParams); if (response.action === "accept" && response.content) { const confirmed = response.content.confirmed as boolean; const note = response.content.note as string | undefined; return { content: [ { type: "text", text: `User ${confirmed ? "confirmed" : "declined"} the action.${note ? `\nNote: ${note}` : ""}`, }, ], }; } else { return { content: [ { type: "text", text: `User ${response.action}ed the confirmation request.`, }, ], }; } } catch (error) { return this.createErrorResponse( `Confirmation request failed: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/index.ts:262-286 (schema)Defines the Tool specification including name, description, and inputSchema for validating 'confirm_action' tool calls.private createConfirmActionTool(): Tool { return { name: "confirm_action", description: "Ask user to confirm an action before proceeding with potentially impactful operations", inputSchema: { type: "object", properties: { action: { type: "string", description: "Description of the action to be confirmed", }, impact: { type: "string", description: "Potential impact or consequences of this action", }, details: { type: "string", description: "Additional details about what will happen", }, }, required: ["action"], }, }; }
- src/index.ts:231-241 (registration)Registers the 'confirm_action' tool by including its creation in the list of available tools returned by listTools handler.private getToolDefinitions(): Tool[] { return [ this.createAskYesNoTool(), this.createConfirmActionTool(), this.createClarifyIntentTool(), this.createVerifyUnderstandingTool(), this.createCollectRatingTool(), this.createElicitCustomTool(), this.createSearchLogsTool(), this.createAnalyzeLogsTool(), ];
- src/index.ts:520-521 (registration)Dispatches 'confirm_action' tool calls to the handleConfirmAction method in the executeToolCall switch statement.case "confirm_action": return await this.handleConfirmAction(args);
- src/index.ts:676-687 (helper)Helper function used by handleConfirmAction to determine appropriate timeout based on action impact level.private determineTimeoutForAction(impact?: string): number { if (!impact) return this.config.defaultTimeoutMs; const impactLower = impact.toLowerCase(); if (impactLower.includes("delete") || impactLower.includes("remove")) { return 120000; // 2 minutes for critical actions } else if (impactLower.includes("warning")) { return 90000; // 1.5 minutes for warning actions } return this.config.defaultTimeoutMs; }