Skip to main content
Glama

get_user_realm_roles

Retrieve realm roles for a specific user in Keycloak. Specify user ID, realm, and whether to include composite roles for comprehensive role assignment details.

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
effectiveNo
realmNo
user_idYes

Implementation Reference

  • The main handler function decorated with @mcp.tool() that implements the get_user_realm_roles tool. It fetches the user's realm roles (effective or direct) from Keycloak using the KeycloakClient.
    @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