ask_yes_no
Get user confirmation through yes/no questions when AI needs clarification or verification during interactions.
Instructions
Ask a yes/no confirmation question to the user when the AI needs clarification or verification
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| question | Yes | The yes/no confirmation question to ask the user |
Implementation Reference
- src/index.ts:945-995 (handler)The handler function for the 'ask_yes_no' tool. It extracts the question from input arguments, constructs an elicitation request schema for a boolean answer, sends the request via sendElicitationRequest, and returns the user's yes/no response or handles errors.private async handleAskYesNo(args: Record<string, unknown>) { const question = typeof args.question === "string" ? args.question : "Please answer yes or no"; const elicitationParams: ElicitationParams = { message: question, requestedSchema: { type: "object", properties: { answer: { type: "boolean", title: "Your Answer", description: "Please select yes or no", }, }, required: ["answer"], }, // Use default timeout instead of hardcoded short timeout timeoutMs: this.config.defaultTimeoutMs, }; try { const response = await this.sendElicitationRequest(elicitationParams); if (response.action === "accept" && response.content) { return { content: [ { type: "text", text: `User answered: ${response.content.answer ? "Yes" : "No"}`, }, ], }; } else { return { content: [ { type: "text", text: `User ${response.action}ed the question.`, }, ], }; } } catch (error) { return this.createErrorResponse( `Elicitation request failed: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/index.ts:244-260 (schema)Defines the schema for the 'ask_yes_no' tool, specifying the name, description, and input schema that requires a 'question' string parameter.private createAskYesNoTool(): Tool { return { name: "ask_yes_no", description: "Ask a yes/no confirmation question to the user when the AI needs clarification or verification", inputSchema: { type: "object", properties: { question: { type: "string", description: "The yes/no confirmation question to ask the user", }, }, required: ["question"], }, }; }
- src/index.ts:231-241 (registration)Registers the 'ask_yes_no' tool as part of the list of available tools returned in response to ListTools requests.private getToolDefinitions(): Tool[] { return [ this.createAskYesNoTool(), this.createConfirmActionTool(), this.createClarifyIntentTool(), this.createVerifyUnderstandingTool(), this.createCollectRatingTool(), this.createElicitCustomTool(), this.createSearchLogsTool(), this.createAnalyzeLogsTool(), ];
- src/index.ts:518-519 (registration)Dispatches 'ask_yes_no' tool calls to the handleAskYesNo handler in the executeToolCall switch statement.case "ask_yes_no": return await this.handleAskYesNo(args);