Skip to main content
Glama
idoyudha

mcp-keycloak

by idoyudha

list_users

Retrieve and filter users in Keycloak realms using pagination, search queries, and attribute filters to manage identity access.

Instructions

List users in the realm.

Args:
    first: Pagination offset
    max: Maximum results size (defaults to 100)
    search: Search string for username, first/last name, or email
    username: Username filter
    email: Email filter
    enabled: Filter by enabled/disabled users
    realm: Target realm (uses default if not specified)

Returns:
    List of user objects

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
firstNo
maxNo
searchNo
usernameNo
emailNo
enabledNo
realmNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The list_users tool handler, registered via @mcp.tool() decorator. It constructs query parameters from inputs and fetches the user list from Keycloak API using the KeycloakClient instance.
    @mcp.tool()
    async def list_users(
        first: Optional[int] = None,
        max: Optional[int] = None,
        search: Optional[str] = None,
        username: Optional[str] = None,
        email: Optional[str] = None,
        enabled: Optional[bool] = None,
        realm: Optional[str] = None,
    ) -> List[Dict[str, Any]]:
        """
        List users in the realm.
    
        Args:
            first: Pagination offset
            max: Maximum results size (defaults to 100)
            search: Search string for username, first/last name, or email
            username: Username filter
            email: Email filter
            enabled: Filter by enabled/disabled users
            realm: Target realm (uses default if not specified)
    
        Returns:
            List of user objects
        """
        params = {}
        if first is not None:
            params["first"] = first
        if max is not None:
            params["max"] = max
        if search:
            params["search"] = search
        if username:
            params["username"] = username
        if email:
            params["email"] = email
        if enabled is not None:
            params["enabled"] = str(enabled).lower()
    
        return await client._make_request("GET", "/users", params=params, realm=realm)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions pagination ('first', 'max') and filtering capabilities, which is helpful, but lacks critical details: whether this is a read-only operation (implied but not stated), what permissions are required, rate limits, or how results are structured beyond 'List of user objects'. For a tool with 7 parameters and no annotation coverage, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (Args, Returns) and uses bullet-like formatting for parameters. Every sentence earns its place by explaining functionality or parameters. It could be slightly more front-loaded by moving the parameter explanations inline, but overall it's efficient and organized.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (7 parameters, no annotations, but has output schema), the description is reasonably complete. It explains all parameters thoroughly and notes the return type. The output schema existence means the description doesn't need to detail return values. However, it lacks behavioral context like permissions or rate limits, which would be valuable for a list operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds substantial value beyond the input schema, which has 0% schema description coverage. It provides clear semantics for all 7 parameters: 'first' as pagination offset, 'max' as maximum results size with default, 'search' as search string scope, and specific filters for username, email, enabled status, and realm. This fully compensates for the schema's lack of descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'List users in the realm.' This is a specific verb+resource combination that distinguishes it from sibling tools like 'get_user' (singular) or 'count_users' (count only). However, it doesn't explicitly differentiate from other list tools like 'list_groups' or 'list_clients' beyond the resource type.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose 'list_users' over 'count_users' (for counting only) or 'get_user' (for retrieving a single user), nor does it specify prerequisites like required permissions or realm access. The agent must infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/idoyudha/mcp-keycloak'

If you have feedback or need assistance with the MCP directory API, please join our Discord server