Skip to main content
Glama
gitCarrot

AWS Cognito MCP Server

by gitCarrot

reset_password_send_code

Send a verification code to reset a user's password in AWS Cognito by providing their username.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYes

Implementation Reference

  • Handler function that initiates password reset by calling forgotPassword on CognitoUser, sending a verification code to the user.
    async ({ username }) => {
        const cognitoUser = new CognitoUser({
            Username: username,
            Pool: userPool,
        });
    
        return new Promise((resolve, reject) => {
            cognitoUser.forgotPassword({
                onSuccess: (data) => {
                    console.log('Password reset request successful:', data);
                    resolve({
                        content: [
                            {
                                type: "text" as const,
                                text: "Code sent successfully",
                            },
                            {
                                type: "text" as const,
                                text: `Delivery method: ${data.CodeDeliveryDetails?.DeliveryMedium || 'Unknown'}`,
                            },
                            {
                                type: "text" as const,
                                text: `Destination: ${data.CodeDeliveryDetails?.Destination || 'Unknown'}`,
                            },
                            {
                                type: "text" as const,
                                text: `Attribute name: ${data.CodeDeliveryDetails?.AttributeName || 'Unknown'}`,
                            }
                        ]
                    });
        },
        onFailure: (err) => {
                    console.error('Password reset request failed:', err.message);
                    reject({
                        content: [
                            {
                                type: "text" as const,
                                text: `Password reset request failed: ${err.message}`,
                            },
                            {
                                type: "text" as const,
                                text: `Error code: ${(err as any).code || 'Unknown'}`,
                            }
                        ]
                    });
                },
            });
        });
    }
  • Input schema for the tool, defining 'username' as a required string using Zod validation.
    {
        username: z.string(),
    },
  • index.ts:280-334 (registration)
    Registration of the 'reset_password_send_code' tool using server.tool(), including inline schema and handler.
    server.tool(
        "reset_password_send_code",
        {
            username: z.string(),
        },
        async ({ username }) => {
            const cognitoUser = new CognitoUser({
                Username: username,
                Pool: userPool,
            });
    
            return new Promise((resolve, reject) => {
                cognitoUser.forgotPassword({
                    onSuccess: (data) => {
                        console.log('Password reset request successful:', data);
                        resolve({
                            content: [
                                {
                                    type: "text" as const,
                                    text: "Code sent successfully",
                                },
                                {
                                    type: "text" as const,
                                    text: `Delivery method: ${data.CodeDeliveryDetails?.DeliveryMedium || 'Unknown'}`,
                                },
                                {
                                    type: "text" as const,
                                    text: `Destination: ${data.CodeDeliveryDetails?.Destination || 'Unknown'}`,
                                },
                                {
                                    type: "text" as const,
                                    text: `Attribute name: ${data.CodeDeliveryDetails?.AttributeName || 'Unknown'}`,
                                }
                            ]
                        });
            },
            onFailure: (err) => {
                        console.error('Password reset request failed:', err.message);
                        reject({
                            content: [
                                {
                                    type: "text" as const,
                                    text: `Password reset request 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