confirm_action
Request user confirmation before executing potentially impactful operations, ensuring explicit approval for actions with significant consequences.
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 | |
| impact | No | Potential impact or consequences of this action | |
| details | No | Additional details about what will happen |
Implementation Reference
- src/index.ts:689-754 (handler)The primary handler function for the 'confirm_action' tool. It constructs a confirmation message based on action, impact, and details, sends an elicitation request to the user, and returns the user's confirmation response.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 object for 'confirm_action' including name, description, and inputSchema specifying required 'action' and optional 'impact' and 'details' parameters.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 createConfirmActionTool() 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:516-537 (registration)Dispatches tool calls to the appropriate handler; routes 'confirm_action' to handleConfirmAction.private async executeToolCall(name: string, args: Record<string, unknown>) { switch (name) { case "ask_yes_no": return await this.handleAskYesNo(args); case "confirm_action": return await this.handleConfirmAction(args); case "clarify_intent": return await this.handleClarifyIntent(args); case "verify_understanding": return await this.handleVerifyUnderstanding(args); case "collect_rating": return await this.handleCollectRating(args); case "elicit_custom": return await this.handleElicitCustom(args); case "search_logs": return await this.handleSearchLogs(args); case "analyze_logs": return await this.handleAnalyzeLogs(args); default: throw new Error(`Unknown tool: ${name}`); } }