Skip to main content
Glama
idoyudha

mcp-keycloak

by idoyudha

create_client_role

Create a new client role in Keycloak to define permissions and access controls for specific applications within your identity management system.

Instructions

Create a new client role.

Args:
    client_id: Client database ID
    name: Role name
    description: Role description
    composite: Whether this is a composite role
    realm: Target realm (uses default if not specified)

Returns:
    Status message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
client_idYes
nameYes
descriptionNo
compositeNo
realmNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'create_client_role' tool, decorated with @mcp.tool() for automatic registration and schema inference. It constructs role data and makes a POST request to Keycloak's client roles endpoint using the KeycloakClient helper.
    @mcp.tool()
    async def create_client_role(
        client_id: str,
        name: str,
        description: Optional[str] = None,
        composite: bool = False,
        realm: Optional[str] = None,
    ) -> Dict[str, str]:
        """
        Create a new client role.
    
        Args:
            client_id: Client database ID
            name: Role name
            description: Role description
            composite: Whether this is a composite role
            realm: Target realm (uses default if not specified)
    
        Returns:
            Status message
        """
        role_data = {"name": name, "composite": composite, "clientRole": True}
    
        if description:
            role_data["description"] = description
    
        await client._make_request(
            "POST", f"/clients/{client_id}/roles", data=role_data, realm=realm
        )
        return {"status": "created", "message": f"Client role {name} created successfully"}
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states it's a creation tool, implying a write operation, but lacks details on permissions required, whether the role is immediately active, error conditions (e.g., duplicate names), or side effects. The return value is vaguely described as 'Status message' without specifying 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 appropriately sized and front-loaded with the main purpose, followed by a structured list of args and returns. Each sentence earns its place by adding necessary information without redundancy, though the 'Returns' section could be more specific.

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) and no annotations, the description is moderately complete: it covers the purpose and parameters well but lacks behavioral details (e.g., auth needs, error handling). The presence of an output schema reduces the need to explain return values in detail, but the vague 'Status message' leaves room for improvement.

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 provides brief but meaningful explanations for all 5 parameters (e.g., 'Client database ID', 'Role name', 'Whether this is a composite role'), clarifying their purposes and default behaviors (e.g., 'uses default if not specified' for realm). This compensates well for the schema's lack of descriptions.

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 ('Create a new client role') with the specific resource ('client role'), which is a distinct operation from sibling tools like 'create_realm_role' or 'create_group'. However, it doesn't explicitly differentiate from these siblings in the description text itself, though the name implies the distinction.

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 like 'create_realm_role' or 'create_group', nor does it mention prerequisites (e.g., needing an existing client). It only lists parameters without contextual usage instructions.

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