Skip to main content
Glama
idoyudha

mcp-keycloak

by idoyudha

get_user_realm_roles

Retrieve realm roles for a Keycloak user, including composite roles if specified, to manage identity and access permissions.

Instructions

Get realm roles for a user.

Args:
    user_id: User ID
    effective: Get effective roles (including composite roles)
    realm: Target realm (uses default if not specified)

Returns:
    List of realm roles

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idYes
effectiveNo
realmNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The @mcp.tool()-decorated handler function that implements the core logic for retrieving a user's realm roles from Keycloak, including support for effective roles.
    @mcp.tool()
    async def get_user_realm_roles(
        user_id: str, effective: bool = False, realm: Optional[str] = None
    ) -> List[Dict[str, Any]]:
        """
        Get realm roles for a user.
    
        Args:
            user_id: User ID
            effective: Get effective roles (including composite roles)
            realm: Target realm (uses default if not specified)
    
        Returns:
            List of realm roles
        """
        endpoint = f"/users/{user_id}/role-mappings/realm"
        if effective:
            endpoint += "/composite"
    
        return await client._make_request("GET", endpoint, realm=realm)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that the tool returns a list of realm roles, which is basic output information, but lacks details on permissions required, rate limits, error handling, or whether it's a read-only operation (implied by 'Get' but not explicit). For a tool with no annotations, this is insufficient to fully inform the agent about behavioral traits.

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

Conciseness5/5

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

The description is appropriately sized and front-loaded, with a clear purpose statement followed by structured sections for 'Args' and 'Returns.' Every sentence earns its place by providing essential information without redundancy, making it easy to parse and understand quickly.

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 moderate complexity (3 parameters, no annotations, but has an output schema), the description is reasonably complete. It covers the purpose, parameters, and return value. Since an output schema exists, the description doesn't need to detail return values further. However, it could improve by adding more behavioral context, such as authentication requirements or error cases, to fully compensate for the lack of annotations.

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

Parameters4/5

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

The description adds meaningful context for all three parameters beyond the input schema, which has 0% description coverage. It explains 'user_id' as 'User ID,' 'effective' as 'Get effective roles (including composite roles),' and 'realm' as 'Target realm (uses default if not specified).' This compensates well for the lack of schema descriptions, providing clear semantics that help the agent understand what each parameter does.

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: 'Get realm roles for a user.' It specifies the verb ('Get') and resource ('realm roles for a user'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'list_realm_roles' or 'get_realm_role,' which also deal with realm roles but in different contexts.

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 sibling tools like 'list_realm_roles' (which lists all realm roles) or 'get_realm_role' (which gets a specific realm role), leaving the agent to infer usage based on the name alone. No explicit when/when-not instructions or prerequisites are included.

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