list_clients
Retrieve and filter client details in a Keycloak realm by ID, visibility, or pagination. Use offsets and limits to manage large datasets efficiently.
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 | ||
| first | No | ||
| max | No | ||
| realm | No | ||
| viewable_only | No |
Implementation Reference
- src/tools/client_tools.py:9-40 (handler)Handler function for the 'list_clients' tool, decorated with @mcp.tool() for automatic registration. Implements listing clients from Keycloak with filtering and pagination parameters using KeycloakClient._make_request.@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)
- src/tools/client_tools.py:9-9 (registration)The @mcp.tool() decorator registers the list_clients function as an MCP tool.@mcp.tool()
- src/tools/client_tools.py:10-16 (schema)Function signature defines input schema (parameters with types and defaults) and output schema (return type annotation).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]]: