remove_all_user_sessions
Terminate all active user sessions in a Keycloak realm to enforce immediate logout and reset authentication states.
Instructions
Remove all sessions for all users in the realm.
Args:
realm: Target realm (uses default if not specified)
Returns:
Status message
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| realm | No |
Implementation Reference
- src/tools/realm_tools.py:267-282 (handler)The handler function for the 'remove_all_user_sessions' tool. It is decorated with @mcp.tool(), which registers the tool. The function logs out all users in the specified realm by making a POST request to the Keycloak '/logout-all' endpoint.@mcp.tool() async def remove_all_user_sessions(realm: Optional[str] = None) -> Dict[str, str]: """ Remove all sessions for all users in the realm. Args: realm: Target realm (uses default if not specified) Returns: Status message """ await client._make_request("POST", "/logout-all", realm=realm) return { "status": "removed", "message": "Sessions for all users removed successfully", }