Skip to main content
Glama
gitCarrot

AWS Cognito MCP Server

by gitCarrot

sign_up

Register new user accounts in AWS Cognito by providing email and password credentials for authentication setup.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
passwordYes
emailYes

Implementation Reference

  • index.ts:25-116 (handler)
    Handler function that creates a CognitoUserAttribute for the email and invokes userPool.signUp to register a new user, handling success and error responses with detailed text content.
    async ({ password, email }) => {
        try {
            const attributeList: CognitoUserAttribute[] = [];
            const dataEmail = {
                Name: 'email',
            Value: email,
            };
            const attributeEmail = new CognitoUserAttribute(dataEmail);
            attributeList.push(attributeEmail);
    
            return new Promise((resolve, reject) => {
                userPool.signUp(email, password, attributeList, attributeList, (err, result) => {
            if (err) {
                console.error('Error signing up:', err);
                        reject({
                            content: [
                                {
                                    type: "text" as const,
                                    text: `Signup failed: ${err.message}`,
                                },
                                {
                                    type: "text" as const,
                                    text: `Error code: ${(err as any).code || 'Unknown'}`,
                                },
                                {
                                    type: "text" as const,
                                    text: `Email used: ${email}`,
                                },
                                {
                                    type: "text" as const,
                                    text: `Password length: ${password.length} characters`,
                                },
                                {
                                    type: "text" as const,
                                    text: `Time: ${new Date().toISOString()}`,
                                }
                            ]
                        });
                    }
                    resolve({
                content: [
                    {
                                type: "text" as const,
                        text: "User created successfully",
                    },
                            {
                                type: "text" as const,
                                text: `User ID: ${result?.userSub}`,
                            },
                            {
                                type: "text" as const,
                                text: `Username: ${result?.user.getUsername()}`,
                            },
                            {
                                type: "text" as const,
                                text: `Email: ${email}`,
                            },
                            {
                                type: "text" as const,
                                text: `Confirmation required: ${!result?.userConfirmed}`,
                            },
                            {
                                type: "text" as const,
                                text: `Time: ${new Date().toISOString()}`,
                            },
                            {
                                type: "text" as const,
                                text: "Check your email for the confirmation code",
                            }
                        ],
                    });
                });
            });
        } catch (error: any) {
            return {
                content : [
                    {
                        type: "text" as const,
                        text: `Error setting AWS Cognito credentials: ${error.message}`,
                    },
                    {
                        type: "text" as const,
                        text: `Stack trace: ${error.stack?.substring(0, 200) || 'Not available'}...`,
                    },
                    {
                        type: "text" as const,
                        text: `Time: ${new Date().toISOString()}`,
                    }
                ]
            }
        }
    }
  • Input schema using Zod validators for 'password' and 'email' strings.
    {
        password: z.string(),
        email: z.string(),
    },
  • index.ts:19-117 (registration)
    MCP server tool registration for 'sign_up' including tool name, input schema, and handler function.
    server.tool(
        "sign_up",
        {
            password: z.string(),
            email: z.string(),
        },
        async ({ password, email }) => {
            try {
                const attributeList: CognitoUserAttribute[] = [];
                const dataEmail = {
                    Name: 'email',
                Value: email,
                };
                const attributeEmail = new CognitoUserAttribute(dataEmail);
                attributeList.push(attributeEmail);
    
                return new Promise((resolve, reject) => {
                    userPool.signUp(email, password, attributeList, attributeList, (err, result) => {
                if (err) {
                    console.error('Error signing up:', err);
                            reject({
                                content: [
                                    {
                                        type: "text" as const,
                                        text: `Signup failed: ${err.message}`,
                                    },
                                    {
                                        type: "text" as const,
                                        text: `Error code: ${(err as any).code || 'Unknown'}`,
                                    },
                                    {
                                        type: "text" as const,
                                        text: `Email used: ${email}`,
                                    },
                                    {
                                        type: "text" as const,
                                        text: `Password length: ${password.length} characters`,
                                    },
                                    {
                                        type: "text" as const,
                                        text: `Time: ${new Date().toISOString()}`,
                                    }
                                ]
                            });
                        }
                        resolve({
                    content: [
                        {
                                    type: "text" as const,
                            text: "User created successfully",
                        },
                                {
                                    type: "text" as const,
                                    text: `User ID: ${result?.userSub}`,
                                },
                                {
                                    type: "text" as const,
                                    text: `Username: ${result?.user.getUsername()}`,
                                },
                                {
                                    type: "text" as const,
                                    text: `Email: ${email}`,
                                },
                                {
                                    type: "text" as const,
                                    text: `Confirmation required: ${!result?.userConfirmed}`,
                                },
                                {
                                    type: "text" as const,
                                    text: `Time: ${new Date().toISOString()}`,
                                },
                                {
                                    type: "text" as const,
                                    text: "Check your email for the confirmation code",
                                }
                            ],
                        });
                    });
                });
            } catch (error: any) {
                return {
                    content : [
                        {
                            type: "text" as const,
                            text: `Error setting AWS Cognito credentials: ${error.message}`,
                        },
                        {
                            type: "text" as const,
                            text: `Stack trace: ${error.stack?.substring(0, 200) || 'Not available'}...`,
                        },
                        {
                            type: "text" as const,
                            text: `Time: ${new Date().toISOString()}`,
                        }
                    ]
                }
            }
        }
    )

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