Skip to main content
Glama

remove_realm_role_from_user

Remove assigned realm roles from a Keycloak user by specifying the user ID and role names. Supports custom realm configuration for targeted role management.

Instructions

Remove realm roles from a user. Args: user_id: User ID role_names: List of role names to remove realm: Target realm (uses default if not specified) Returns: Status message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
realmNo
role_namesYes
user_idYes

Implementation Reference

  • The core handler function that executes the tool: fetches the role representations and sends a DELETE request to Keycloak's user role-mappings endpoint to remove the roles from the user.
    async def remove_realm_role_from_user( user_id: str, role_names: List[str], realm: Optional[str] = None ) -> Dict[str, str]: """ Remove realm roles from a user. Args: user_id: User ID role_names: List of role names to remove realm: Target realm (uses default if not specified) Returns: Status message """ # Get role representations roles = [] for role_name in role_names: role = await client._make_request("GET", f"/roles/{role_name}", realm=realm) roles.append(role) await client._make_request( "DELETE", f"/users/{user_id}/role-mappings/realm", data=roles, realm=realm ) return { "status": "removed", "message": f"Roles {role_names} removed from user {user_id}", }
  • The @mcp.tool() decorator registers this function as an MCP tool named 'remove_realm_role_from_user' based on the function name, with schema inferred from type hints and docstring.
    @mcp.tool()

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