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

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)

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