Skip to main content
Glama
mrz1880

mcp-keycloak-admin

Assign a realm role to a user

keycloak_user_role_assign
Idempotent

Assign a realm-level role to a user in Keycloak. The operation is idempotent and returns confirmation or an explanation if the user or role is not found.

Instructions

Write: grants a single realm-level role to a user (not a client role). This is idempotent — assigning a role the user already has succeeds without changing anything. The role must already exist in the realm; list candidates with keycloak_role_list and verify current assignments with keycloak_user_roles_get. Returns a confirmation that the role was assigned, or a message explaining why it was not (for example, the user or role was not found).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
roleYesThe name of an existing realm role to grant (e.g. 'admin'), as returned by keycloak_role_list. This is the role name, not its ID.
userIdYesThe Keycloak user ID (the user's UUID, e.g. 'f47ac10b-58cc-4372-a567-0e02b2c3d479'), not the username. Identifies the user who receives the role.
Behavior4/5

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

Annotations already declare idempotentHint=true, destructiveHint=false, and readOnlyHint=false. The description adds context by confirming idempotency explicitly ('assigning a role the user already has succeeds without changing anything') and describes the return behavior (confirmation or failure message). It also discloses the precondition that the role must exist, which is beyond annotations but not contradictory.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, highly efficient. The first sentence conveys the core action, scope, and idempotency. The second sentence covers preconditions, alternative tools, and expected return. No extraneous words.

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

Completeness5/5

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

Given the tool's simplicity (2 required params, no output schema), the description covers all essential aspects: what it does, scope (realm role vs client role), idempotency, preconditions, return format, and related tools. It is complete for an agent to understand when and how to invoke it correctly.

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?

The input schema covers both parameters with full descriptions (100% coverage). The description does not add new semantic information about the parameters beyond what the schema already provides, such as clarifying that userId is a UUID and role is a realm role name. Thus, baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'grants a single realm-level role to a user (not a client role)', immediately distinguishing the tool from role assignment for client roles and specifying the scope as realm-level. The verb 'grants' is specific and the resource (realm role to a user) is unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance: it notes this is for realm roles, not client roles, and suggests listing candidates with keycloak_role_list and verifying current assignments with keycloak_user_roles_get. It implies when not to use (for client roles) but does not explicitly mention the sibling keycloak_user_client_role_assign, which would be ideal. The context of idempotency and precondition (role must exist) is clear.

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/mrz1880/mcp-keycloak-admin'

If you have feedback or need assistance with the MCP directory API, please join our Discord server