Skip to main content
Glama
gitCarrot

AWS Cognito MCP Server

by gitCarrot

reset_password_veryify_code

Verify a password reset code and set a new password for AWS Cognito users. Provide username, verification code, and new password to complete the reset process.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYes
codeYes
newPasswordYes

Implementation Reference

  • The handler function for the reset_password_veryify_code tool. It creates a CognitoUser instance and uses confirmPassword to verify the code and set the new password, returning success or error messages.
    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'}`,
                            }
                        ]
                    });
                }
            });
        });
    }
  • Zod schema defining the input parameters: username, code, and newPassword.
    {
        username: z.string(),
        code: z.string(),
        newPassword: z.string(),
    },
  • index.ts:336-392 (registration)
    Registration of the reset_password_veryify_code tool using server.tool, including name, schema, and handler.
    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'}`,
                                }
                            ]
                        });
                    }
                });
            });
        }
    )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gitCarrot/mcp-server-aws-cognito'

If you have feedback or need assistance with the MCP directory API, please join our Discord server