Skip to main content
Glama
HaithamOumerzoug

Keycloak MCP Server

list-users

Retrieve a list of users within a specified Keycloak realm using the MCP server, enabling efficient user management and administrative oversight.

Instructions

List users in a specific realm

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
realmYes

Implementation Reference

  • The main implementation of the list-users tool, which parses input arguments using ListUsersSchema, queries Keycloak for users in the specified realm, and returns a formatted list.
    public async listUsers(args: unknown): Promise<string> {
      const { realm } = ListUsersSchema.parse(args);
      const users: UserRepresentation[] = await this.kcAdminClient.users.find({
        realm,
      });
      return `Users in realm ${realm}:\n${users
        .map((u) => `- ${u.username} (${u.id})`)
        .join("\n")}`;
    }
  • Zod input schema for validating arguments in the listUsers handler (requires 'realm' string).
    export const ListUsersSchema = z.object({
      realm: z.string(),
    });
  • JSON Schema definition for list-users tool input, used in tool registration (requires 'realm' string).
    "list-users": {
      type: "object",
      properties: {
        realm: { type: "string" },
      },
      required: ["realm"],
    },
  • src/server.ts:52-56 (registration)
    Registration of the list-users tool in the ListToolsRequestHandler response.
      name: "list-users",
      description: "List users in a specific realm",
      inputSchema: InputSchema["list-users"],
    },
    {
  • Handler dispatch in CallToolRequestHandler that calls the Keycloak service's listUsers method.
    case "list-users":
      return {
        content: [
          { type: "text", text: await keycloakService.listUsers(args) },
        ],
      };
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. It states 'list users' which implies a read-only operation, but does not disclose behavioral traits such as pagination, sorting, filtering beyond realm, authentication requirements, rate limits, or what the output format looks like. This is a significant gap for a tool with no annotation coverage.

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, clear sentence with zero waste. It is appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration.

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 no annotations, 0% schema coverage, no output schema, and a simple parameter structure, the description is incomplete. It lacks details on behavior, output, parameter meaning, and usage context, making it inadequate for an agent to reliably invoke the tool without additional assumptions.

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 description must compensate. It mentions 'in a specific realm', which hints at the 'realm' parameter's purpose, but does not explain what a realm is, its format, valid values, or how it affects the listing. With 1 undocumented parameter, the description adds minimal semantic value beyond the schema.

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 the resource 'users in a specific realm', which is specific and unambiguous. However, it does not distinguish this tool from potential siblings like 'list-groups' or 'list-clients' beyond the resource name, as all share the same 'list' pattern without explicit differentiation in the description.

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 mentions 'in a specific realm' but does not specify prerequisites, exclusions, or compare it to other user-related tools like 'create-user' or 'list-client-roles', leaving usage context implied at best.

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