list_clients
Retrieve and filter client applications from a Keycloak realm to manage access control and permissions.
Instructions
List clients in the realm.
Args:
client_id: Filter by client ID (partial match)
viewable_only: Only return viewable clients
first: Pagination offset
max: Maximum results size
realm: Target realm (uses default if not specified)
Returns:
List of client objects
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| client_id | No | ||
| viewable_only | No | ||
| first | No | ||
| max | No | ||
| realm | No |
Implementation Reference
- src/tools/client_tools.py:9-40 (handler)The handler function for the 'list_clients' MCP tool. It is decorated with @mcp.tool() for registration and implements the logic to list Keycloak clients with optional filtering, pagination, and realm specification using the KeycloakClient instance.@mcp.tool() async def list_clients( client_id: Optional[str] = None, viewable_only: bool = False, first: Optional[int] = None, max: Optional[int] = None, realm: Optional[str] = None, ) -> List[Dict[str, Any]]: """ List clients in the realm. Args: client_id: Filter by client ID (partial match) viewable_only: Only return viewable clients first: Pagination offset max: Maximum results size realm: Target realm (uses default if not specified) Returns: List of client objects """ params = {} if client_id: params["clientId"] = client_id if viewable_only: params["viewableOnly"] = "true" if first is not None: params["first"] = first if max is not None: params["max"] = max return await client._make_request("GET", "/clients", params=params, realm=realm)