delete-user
Remove a user from a specific realm in Keycloak using the MCP server. Specify the realm and user ID to ensure accurate deletion, streamlining user management tasks.
Instructions
Delete a user from a specific realm
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| realm | Yes | ||
| userId | Yes |
Implementation Reference
- src/services/keycloak.ts:42-46 (handler)Implements the core logic for deleting a user: validates input with DeleteUserSchema, deletes via Keycloak admin client users.del, and returns success message.public async deleteUser(args: unknown): Promise<string> { const { realm, userId } = DeleteUserSchema.parse(args); await this.kcAdminClient.users.del({ id: userId, realm }); return `User ${userId} deleted successfully from realm ${realm}`; }
- src/server.ts:101-106 (handler)Dispatches the delete-user tool invocation to KeycloakService.deleteUser in the CallToolRequest handler.case "delete-user": return { content: [ { type: "text", text: await keycloakService.deleteUser(args) }, ], };
- src/schemas/index.ts:58-65 (schema)JSON Schema definition for delete-user tool input parameters, referenced in tool registration."delete-user": { type: "object", properties: { realm: { type: "string" }, userId: { type: "string" }, }, required: ["realm", "userId"], },
- src/schemas/index.ts:11-14 (schema)Zod validation schema for delete-user input arguments, used in the service handler.export const DeleteUserSchema = z.object({ realm: z.string(), userId: z.string(), });
- src/server.ts:41-45 (registration)Registers the delete-user tool in the MCP server's ListTools response with name, description, and input schema.{ name: "delete-user", description: "Delete a user from a specific realm", inputSchema: InputSchema["delete-user"], },