Skip to main content
Glama
idoyudha

mcp-keycloak

by idoyudha

remove_realm_role_from_user

Remove realm roles from a Keycloak user to manage access permissions. Specify user ID and role names to revoke specific privileges in identity 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
user_idYes
role_namesYes
realmNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function decorated with @mcp.tool(), implementing the logic to remove realm roles from a user by fetching roles and deleting mappings via Keycloak API.
    @mcp.tool()
    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}",
        }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the action is a removal operation, implying mutation, but doesn't disclose behavioral traits like whether this requires admin permissions, if changes are reversible, what happens if roles aren't assigned, or any rate limits. The description is minimal and lacks critical context for a destructive operation.

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 appropriately sized and front-loaded with the core purpose first, followed by parameter and return sections. Every sentence earns its place, though the parameter explanations are very brief. No redundant information is present, and structure is clear with labeled sections.

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

Completeness3/5

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

Given the tool's complexity (mutation with 3 parameters), no annotations, and an output schema (which covers return values), the description is minimally complete. It states purpose and parameters but lacks behavioral context, error handling, or usage guidance. The output schema helps, but for a role removal tool, more context on permissions and effects is needed.

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

Parameters3/5

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

Schema description coverage is 0%, so the description must compensate. It lists all three parameters with brief explanations, adding meaning beyond the schema's titles. However, it doesn't provide format details (e.g., user_id format, role name constraints), default behavior for 'realm', or examples. The baseline is lowered due to low coverage, but some value is added.

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 action ('Remove realm roles from a user') with specific verb and resource. It distinguishes from siblings like 'remove_user_from_group' or 'remove_realm_default_group' by specifying realm roles and user focus. However, it doesn't explicitly contrast with 'assign_realm_role_to_user' or other role management tools.

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?

No guidance on when to use this tool versus alternatives. While the purpose is clear, there's no mention of prerequisites (e.g., user must exist, roles must be assigned), when not to use it, or explicit alternatives like 'update_user' for role management. The context of sibling tools suggests multiple role/user management options without differentiation.

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