Skip to main content
Glama
gitCarrot

AWS Cognito MCP Server

by gitCarrot

delete_user

Remove a user account from AWS Cognito to manage authentication access and maintain user directory security.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function that executes the delete_user tool logic: retrieves current Cognito user, verifies session, deletes the user using cognitoUser.deleteUser(), and returns success/error messages.
        async ({}) => {
            return new Promise((resolve, reject) => {
            const cognitoUser = userPool.getCurrentUser();
                if (!cognitoUser) {
                    resolve({
                        content: [
                            {
                                type: "text" as const,
                                text: "No user currently signed in",
                            }
                        ]
                    });
                    return;
                }
    
                cognitoUser.getSession((err: Error | null, _session: CognitoUserSession) => {
                    if (err) {
                        reject({
                            content: [
                                {
                                    type: "text" as const,
                                    text: `Error getting session: ${err.message}`,
                                }
                            ]
                        });
                        return;
                    }
    
                    const username = cognitoUser.getUsername();
                    cognitoUser.deleteUser((err, result) => {
                if (err) {
                            reject({
                                content: [
                                    {
                                        type: "text" as const,
                                        text: `Failed to delete user: ${err.message}`,
                                    },
                                    {
                                        type: "text" as const,
                                        text: `Error code: ${(err as any).code || 'Unknown'}`,
                                    }
                                ]
                            });
                            return;
                        }
    
                        resolve({
                            content: [
                                {
                                    type: "text" as const,
                                    text: "User deleted successfully",
                                },
                                {
                                    type: "text" as const,
                                    text: `Username: ${username}`,
                                },
                                {
                                    type: "text" as const,
                                    text: `Result: ${result}`,
                                },
                                {
                                    type: "text" as const,
                                    text: `Time: ${new Date().toISOString()}`,
                                }
                            ]
                        });
                    });
                });
            });
        }
    )
  • index.ts:711-786 (registration)
    Registration of the 'delete_user' tool via server.tool(), with empty input schema and inline handler function.
    server.tool(
        "delete_user",
        {
        },
        async ({}) => {
            return new Promise((resolve, reject) => {
            const cognitoUser = userPool.getCurrentUser();
                if (!cognitoUser) {
                    resolve({
                        content: [
                            {
                                type: "text" as const,
                                text: "No user currently signed in",
                            }
                        ]
                    });
                    return;
                }
    
                cognitoUser.getSession((err: Error | null, _session: CognitoUserSession) => {
                    if (err) {
                        reject({
                            content: [
                                {
                                    type: "text" as const,
                                    text: `Error getting session: ${err.message}`,
                                }
                            ]
                        });
                        return;
                    }
    
                    const username = cognitoUser.getUsername();
                    cognitoUser.deleteUser((err, result) => {
                if (err) {
                            reject({
                                content: [
                                    {
                                        type: "text" as const,
                                        text: `Failed to delete user: ${err.message}`,
                                    },
                                    {
                                        type: "text" as const,
                                        text: `Error code: ${(err as any).code || 'Unknown'}`,
                                    }
                                ]
                            });
                            return;
                        }
    
                        resolve({
                            content: [
                                {
                                    type: "text" as const,
                                    text: "User deleted successfully",
                                },
                                {
                                    type: "text" as const,
                                    text: `Username: ${username}`,
                                },
                                {
                                    type: "text" as const,
                                    text: `Result: ${result}`,
                                },
                                {
                                    type: "text" as const,
                                    text: `Time: ${new Date().toISOString()}`,
                                }
                            ]
                        });
                    });
                });
            });
        }
    )
  • Empty input schema for the delete_user tool (no parameters required).
    {
    },

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