delete_user
Remove a user from AWS Cognito user pool to manage access control and maintain user directory integrity by deleting user accounts.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.ts:711-712 (registration)Registration of the 'delete_user' tool using server.tool()server.tool( "delete_user",
- index.ts:713-714 (schema)Empty input schema for delete_user tool (no input parameters required){ },
- index.ts:715-784 (handler)Handler function for the delete_user tool. It retrieves the current Cognito user, verifies the session, extracts the username, calls cognitoUser.deleteUser(), and returns success or 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()}`, } ] }); }); }); }); }