delete_user
Remove a user from the MCP Keycloak server by specifying their user ID and optional realm. Ensures identity and access management cleanup with a clear status response.
Instructions
Delete a user.
Args:
user_id: The user's ID
realm: Target realm (uses default if not specified)
Returns:
Status message
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| realm | No | ||
| user_id | Yes |
Implementation Reference
- src/tools/user_tools.py:174-187 (handler)The delete_user tool handler, decorated with @mcp.tool() for registration. It deletes the specified user via the Keycloak client by sending a DELETE request to the /users/{user_id} endpoint and returns a success message.@mcp.tool() async def delete_user(user_id: str, realm: Optional[str] = None) -> Dict[str, str]: """ Delete a user. Args: user_id: The user's ID realm: Target realm (uses default if not specified) Returns: Status message """ await client._make_request("DELETE", f"/users/{user_id}", realm=realm) return {"status": "deleted", "message": f"User {user_id} deleted successfully"}