count_users
Retrieve the total number of users in a Keycloak realm to monitor user base size and manage 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 main handler function for the 'count_users' tool. It is decorated with @mcp.tool(), which likely handles both registration and schema inference from the function signature and docstring. The function calls the Keycloak client's _make_request method to GET /users/count endpoint to retrieve the user count for the specified realm.@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)