delete-user
Remove a user from a specified realm in the Keycloak MCP server by providing the realm name and user ID for precise deletion.
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)MCP tool handler for 'delete-user': parses arguments with Zod schema, calls KeycloakService.deleteUser, and 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:136-144 (helper)Core logic in KeycloakService to delete a user by ID from a realm using 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, }); }
- src/index.ts:462-465 (schema)Zod schema for validating delete-user tool input parameters.const DeleteUserSchema = z.object({ realm: z.string(), userId: z.string(), });
- src/index.ts:366-376 (registration)Tool registration in listTools response, including name, description, and JSON 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"], }, },