count_users
Retrieve the total number of users within a specified or default Keycloak realm. Simplifies user management by providing accurate counts for identity and access control.
Instructions
Count all users.
Args:
realm: Target realm (uses default if not specified)
Returns:
Number of users
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| realm | No |
Implementation Reference
- src/tools/user_tools.py:250-262 (handler)The handler function for the 'count_users' tool. It is decorated with @mcp.tool() for registration and uses KeycloakClient to fetch the user count from the '/users/count' endpoint.@mcp.tool() async def count_users(realm: Optional[str] = None) -> int: """ Count all users. Args: realm: Target realm (uses default if not specified) Returns: Number of users """ return await client._make_request("GET", "/users/count", realm=realm)