resend_confirmation_code
Resend email confirmation code for AWS Cognito user accounts when the initial verification message is not received or has expired.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes |
Implementation Reference
- index.ts:795-845 (handler)The handler function executes the resend confirmation code logic using AWS CognitoUser.resendConfirmationCode, handling errors and success responses.async ({ username }) => { return new Promise((resolve, reject) => { const cognitoUser = new CognitoUser({ Username: username, Pool: userPool }); cognitoUser.resendConfirmationCode((err, result) => { if (err) { reject({ content: [ { type: "text" as const, text: `Failed to resend confirmation code: ${err.message}`, }, { type: "text" as const, text: `Error code: ${(err as any).code || 'Unknown'}`, } ] }); return; } resolve({ content: [ { type: "text" as const, text: "Confirmation code resent successfully", }, { type: "text" as const, text: `Username: ${username}`, }, { type: "text" as const, text: `Delivery method: ${result?.CodeDeliveryDetails?.DeliveryMedium || 'Unknown'}`, }, { type: "text" as const, text: `Destination: ${result?.CodeDeliveryDetails?.Destination || 'Unknown'}`, }, { type: "text" as const, text: `Time: ${new Date().toISOString()}`, } ] }); }); }); }
- index.ts:792-794 (schema)Zod schema defining the input parameter 'username' as a string.{ username: z.string() },
- index.ts:790-846 (registration)Registration of the 'resend_confirmation_code' tool with server.tool, including name, schema, and inline handler.server.tool( "resend_confirmation_code", { username: z.string() }, async ({ username }) => { return new Promise((resolve, reject) => { const cognitoUser = new CognitoUser({ Username: username, Pool: userPool }); cognitoUser.resendConfirmationCode((err, result) => { if (err) { reject({ content: [ { type: "text" as const, text: `Failed to resend confirmation code: ${err.message}`, }, { type: "text" as const, text: `Error code: ${(err as any).code || 'Unknown'}`, } ] }); return; } resolve({ content: [ { type: "text" as const, text: "Confirmation code resent successfully", }, { type: "text" as const, text: `Username: ${username}`, }, { type: "text" as const, text: `Delivery method: ${result?.CodeDeliveryDetails?.DeliveryMedium || 'Unknown'}`, }, { type: "text" as const, text: `Destination: ${result?.CodeDeliveryDetails?.Destination || 'Unknown'}`, }, { type: "text" as const, text: `Time: ${new Date().toISOString()}`, } ] }); }); }); } )