delete-user
Remove a user from a Keycloak realm by specifying the realm name and user ID to manage access control.
Instructions
Delete a user from a specific realm
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| realm | Yes | Realm name | |
| userId | Yes | User ID to delete |
Implementation Reference
- src/index.ts:510-521 (handler)Handler for 'delete-user' tool: parses arguments, calls KeycloakService.deleteUser, returns success message.case "delete-user": { const { realm, userId } = DeleteUserSchema.parse(args); await keycloakService.deleteUser(realm, userId); return { content: [ { type: "text", text: `User ${userId} deleted successfully from realm ${realm}`, }, ], }; }
- src/index.ts:462-465 (schema)Zod schema for validating input arguments of 'delete-user' tool.const DeleteUserSchema = z.object({ realm: z.string(), userId: z.string(), });
- src/index.ts:366-376 (registration)Tool registration in listTools response, defining name, description, and input schema.name: "delete-user", description: "Delete a user from a specific realm", inputSchema: { type: "object", properties: { realm: { type: "string", description: "Realm name" }, userId: { type: "string", description: "User ID to delete" }, }, required: ["realm", "userId"], }, },
- src/index.ts:136-144 (helper)KeycloakService method implementing the actual user deletion logic via Keycloak Admin Client.async deleteUser(realm: string, userId: string) { await this.authenticate(); this.client.setConfig({ realmName: realm }); await this.client.users.del({ id: userId, realm, }); }