Skip to main content
Glama
HaithamOumerzoug

Keycloak MCP Server

list-groups

Retrieve a list of groups within a specified Keycloak realm using the MCP server. Manage group data efficiently within Keycloak environments.

Instructions

List groups in a specific realm

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
realmYes

Implementation Reference

  • Executes the tool logic: parses arguments with ListGroupsSchema, queries Keycloak admin client for groups in the specified realm, and returns a formatted text list.
    public async listGroups(args: unknown): Promise<string> {
      const { realm } = ListGroupsSchema.parse(args);
      const groups: GroupRepresentation[] = await this.kcAdminClient.groups.find({
        realm,
      });
      return `Groups in realm ${realm}:\n${groups
        .map((g) => `- ${g.name} (${g.id})`)
        .join("\n")}`;
    }
  • Tool dispatcher in the CallToolRequestSchema handler that calls the KeycloakService.listGroups method.
    case "list-groups":
      return {
        content: [
          { type: "text", text: await keycloakService.listGroups(args) },
        ],
      };
  • InputSchema definition for 'list-groups' tool used in registration and validation.
    "list-groups": {
      type: "object",
      properties: {
        realm: { type: "string" },
      },
      required: ["realm"],
    },
  • src/server.ts:72-75 (registration)
    Registers the 'list-groups' tool in the ListToolsRequestSchema response.
      name: "list-groups",
      description: "List groups in a specific realm",
      inputSchema: InputSchema["list-groups"],
    },
  • Zod schema used for input validation inside the listGroups handler.
    export const ListGroupsSchema = z.object({
      realm: z.string(),
    });
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It implies a read operation but doesn't disclose pagination, sorting, filtering, permissions needed, rate limits, or what the output contains. 'List' suggests non-destructive behavior, but this isn't explicitly stated.

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 no wasted words. It's front-loaded with the core action and scope, making it easy to parse quickly.

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?

For a tool with no annotations, no output schema, and minimal parameter documentation, the description is insufficient. It doesn't cover what the output looks like, error conditions, or how it differs from sibling list tools, leaving the agent with significant uncertainty.

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%, but there's only one parameter ('realm'). The description adds context by specifying 'in a specific realm', which helps interpret the parameter. However, it doesn't explain what a 'realm' is, its format, or provide examples, leaving gaps.

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 verb ('List') and resource ('groups'), and specifies the scope ('in a specific realm'). It doesn't differentiate from sibling tools like 'list-users' or 'list-realms', but the purpose 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 Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'list-users' or 'list-client-roles'. The description mentions 'in a specific realm' but doesn't explain if this is required for all list operations or unique to this tool.

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