list_groups
Retrieve groups from Keycloak realms with pagination and search filters to manage user access and organization structures.
Instructions
List all groups in the realm.
Args:
first: Pagination offset
max: Maximum results size
search: Search string
realm: Target realm (uses default if not specified)
Returns:
List of groups
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| first | No | ||
| max | No | ||
| search | No | ||
| realm | No |
Implementation Reference
- src/tools/group_tools.py:9-36 (handler)The 'list_groups' tool handler function, including the @mcp.tool() decorator which handles registration and schema via type annotations and docstring. This implements the core logic to list Keycloak groups using the KeycloakClient.@mcp.tool() async def list_groups( first: Optional[int] = None, max: Optional[int] = None, search: Optional[str] = None, realm: Optional[str] = None, ) -> List[Dict[str, Any]]: """ List all groups in the realm. Args: first: Pagination offset max: Maximum results size search: Search string realm: Target realm (uses default if not specified) Returns: List of groups """ params = {} if first is not None: params["first"] = first if max is not None: params["max"] = max if search: params["search"] = search return await client._make_request("GET", "/groups", params=params, realm=realm)