delete_user
Remove a user account from AWS Cognito to manage authentication access and maintain user directory security.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "delete_user"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.ts:715-785 (handler)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()}`, } ] }); }); }); }); } ) - index.ts:713-714 (schema)Empty input schema for the delete_user tool (no parameters required).
{ },