list_realm_roles
Retrieve a list of realm roles with pagination, search, and realm-specific filtering options for efficient Keycloak role management.
Instructions
List all realm roles.
Args:
first: Pagination offset
max: Maximum results size
search: Search string
realm: Target realm (uses default if not specified)
Returns:
List of realm roles
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| first | No | ||
| max | No | ||
| realm | No | ||
| search | No |
Implementation Reference
- src/tools/role_tools.py:9-36 (handler)The handler function for the list_realm_roles tool, decorated with @mcp.tool() which also handles registration. It constructs query parameters for pagination and search, then calls the Keycloak client's request method to fetch realm roles.@mcp.tool() async def list_realm_roles( first: Optional[int] = None, max: Optional[int] = None, search: Optional[str] = None, realm: Optional[str] = None, ) -> List[Dict[str, Any]]: """ List all realm roles. Args: first: Pagination offset max: Maximum results size search: Search string realm: Target realm (uses default if not specified) Returns: List of realm roles """ 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", "/roles", params=params, realm=realm)
- src/tools/__init__.py:5-5 (registration)Import of role_tools module in tools __init__.py, which executes the @mcp.tool() decorators to register the list_realm_roles tool among others.from . import role_tools