Skip to main content
Glama
HaithamOumerzoug

Keycloak MCP Server

list-client-roles

Retrieve roles for a specific client in Keycloak realms using the Model Context Protocol server, enabling efficient management of user permissions and access rights.

Instructions

List roles in a specific client

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clientUniqueIdYes
realmYes

Implementation Reference

  • The core handler function that parses input arguments, fetches client roles from Keycloak Admin Client, and returns a formatted list.
    public async listClientRoles(args: unknown): Promise<string> {
      const { realm, clientUniqueId } = ListClientRolesSchema.parse(args);
      const roles: RoleRepresentation[] =
        await this.kcAdminClient.clients.listRoles({
          id: clientUniqueId,
          realm,
        });
      return `Roles in client ${clientUniqueId} in realm ${realm}:\n${roles
        .map((r) => `- ${r.name}`)
        .join("\n")}`;
    }
  • JSON schema definition for the 'list-client-roles' tool input, used in tool registration.
    "list-client-roles": {
      type: "object",
      properties: {
        realm: { type: "string" },
        clientUniqueId: { type: "string" },
      },
      required: ["realm", "clientUniqueId"],
    },
  • src/server.ts:76-80 (registration)
    Tool registration in the ListTools response, including name, description, and input schema reference.
    {
      name: "list-client-roles",
      description: "List roles in a specific client",
      inputSchema: InputSchema["list-client-roles"],
    },
  • Dispatch handler in the CallToolRequest switch statement that invokes the KeycloakService handler.
    case "list-client-roles":
      return {
        content: [
          {
            type: "text",
            text: await keycloakService.listClientRoles(args),
          },
        ],
      };
  • Zod schema for input validation used within the handler.
    export const ListClientRolesSchema = z.object({
      realm: z.string(),
      clientUniqueId: z.string(),
    });
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 list operation, implying read-only behavior, but doesn't clarify if it's safe, paginated, or has rate limits. For a tool with zero annotation coverage, this minimal description fails to provide adequate behavioral context beyond the basic action.

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?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly. Every word earns its place, achieving optimal conciseness for such a straightforward tool.

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

Completeness2/5

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

Given the tool's moderate complexity (2 required parameters, no output schema, no annotations), the description is incomplete. It lacks parameter explanations, usage context, behavioral details, and output information. While concise, it doesn't provide enough information for an agent to use the tool effectively without additional guessing.

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

Parameters2/5

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

Schema description coverage is 0%, so the schema provides no parameter details. The description mentions 'in a specific client' but doesn't explain the two required parameters (realm, clientUniqueId) or their semantics (e.g., what a realm is, how to obtain clientUniqueId). It adds minimal value beyond the schema, insufficient for the coverage gap.

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 ('List') and resource ('roles in a specific client'), making the purpose immediately understandable. It distinguishes itself from siblings like 'list-clients' or 'list-users' by focusing on client roles. However, it doesn't specify whether this lists all roles or filtered ones, keeping it from 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., needing realm and client IDs), compare to siblings like 'assign-client-role-to-user', or specify use cases (e.g., for auditing or role assignment). This leaves the agent without contextual usage cues.

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

Related 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/HaithamOumerzoug/keycloak-mcp'

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