reset_password_veryify_code
Verify a password reset code and set a new password for AWS Cognito users to regain account access after requesting a reset.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| newPassword | Yes | ||
| username | Yes |
Implementation Reference
- index.ts:343-391 (handler)Executes the tool logic: confirms the password reset code using AWS Cognito's confirmPassword method, updates password on success, returns formatted response.async ({ username, code, newPassword }) => { const cognitoUser = new CognitoUser({ Username: username, Pool: userPool, }); return new Promise((resolve, reject) => { cognitoUser.confirmPassword(code, newPassword, { onSuccess: () => { console.log('Password reset completed'); resolve({ content: [ { type: "text" as const, text: "Password reset successfully", }, { type: "text" as const, text: `Username: ${username}`, }, { type: "text" as const, text: `Verification code: ${code.substr(0, 2)}****${code.substr(-2)}`, }, { type: "text" as const, text: `Password length: ${newPassword.length} characters`, } ] }); }, onFailure: (err) => { console.error('Password reset failed:', err.message); reject({ content: [ { type: "text" as const, text: `Password reset failed: ${err.message}`, }, { type: "text" as const, text: `Error code: ${(err as any).code || 'Unknown'}`, } ] }); } }); }); }
- index.ts:338-342 (schema)Zod schema for input validation: requires username, verification code, and new password.{ username: z.string(), code: z.string(), newPassword: z.string(), },
- index.ts:336-392 (registration)Registers the MCP tool 'reset_password_veryify_code' with schema and handler implementation.server.tool( "reset_password_veryify_code", { username: z.string(), code: z.string(), newPassword: z.string(), }, async ({ username, code, newPassword }) => { const cognitoUser = new CognitoUser({ Username: username, Pool: userPool, }); return new Promise((resolve, reject) => { cognitoUser.confirmPassword(code, newPassword, { onSuccess: () => { console.log('Password reset completed'); resolve({ content: [ { type: "text" as const, text: "Password reset successfully", }, { type: "text" as const, text: `Username: ${username}`, }, { type: "text" as const, text: `Verification code: ${code.substr(0, 2)}****${code.substr(-2)}`, }, { type: "text" as const, text: `Password length: ${newPassword.length} characters`, } ] }); }, onFailure: (err) => { console.error('Password reset failed:', err.message); reject({ content: [ { type: "text" as const, text: `Password reset failed: ${err.message}`, }, { type: "text" as const, text: `Error code: ${(err as any).code || 'Unknown'}`, } ] }); } }); }); } )