Skip to main content
Glama
idoyudha

mcp-keycloak

by idoyudha

create_realm_role

Create a new realm role in Keycloak for identity and access management, specifying name, description, composite status, client role status, and target realm.

Instructions

Create a new realm role.

Args:
    name: Role name
    description: Role description
    composite: Whether this is a composite role
    client_role: Whether this is a client role
    realm: Target realm (uses default if not specified)

Returns:
    Status message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
descriptionNo
compositeNo
client_roleNo
realmNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'create_realm_role' tool. It uses the KeycloakClient to POST a new role to the /roles endpoint, decorated with @mcp.tool() for registration.
    @mcp.tool()
    async def create_realm_role(
        name: str,
        description: Optional[str] = None,
        composite: bool = False,
        client_role: bool = False,
        realm: Optional[str] = None,
    ) -> Dict[str, str]:
        """
        Create a new realm role.
    
        Args:
            name: Role name
            description: Role description
            composite: Whether this is a composite role
            client_role: Whether this is a client role
            realm: Target realm (uses default if not specified)
    
        Returns:
            Status message
        """
        role_data = {"name": name, "composite": composite, "clientRole": client_role}
    
        if description:
            role_data["description"] = description
    
        await client._make_request("POST", "/roles", data=role_data, realm=realm)
        return {"status": "created", "message": f"Realm role {name} created successfully"}
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 states the tool creates a new realm role, implying a write operation, but doesn't mention critical details like required permissions, whether the role name must be unique, what happens on failure, or any rate limits. The return value is vaguely described as 'Status message,' lacking specifics on success/error formats.

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 well-structured and appropriately sized, using clear sections ('Args,' 'Returns') for easy parsing. Every sentence adds value, with no redundant information. It could be slightly more concise by integrating the parameter explanations into a single paragraph, but overall it's efficient.

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 (a write operation with 5 parameters), lack of annotations, and an output schema (implied by 'Returns'), the description is moderately complete. It covers parameters and return value at a high level but misses behavioral details like permissions, uniqueness rules, and error handling. The output schema existence reduces the need to explain returns in depth, but more context is needed for safe use.

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 significant value beyond the input schema, which has 0% schema description coverage. It explains each parameter's purpose (e.g., 'Role name,' 'Whether this is a composite role'), clarifying semantics that the schema's titles alone don't provide. However, it doesn't detail constraints like name format or realm validity, preventing a perfect score.

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: 'Create a new realm role.' This is a specific verb ('Create') and resource ('realm role'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'create_client_role' or 'update_realm_role,' which would be needed for a perfect score.

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 prerequisites (e.g., required permissions), when not to use it, or how it differs from similar tools like 'create_client_role' or 'update_realm_role' in the sibling list. This lack of context leaves the agent to infer usage scenarios.

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