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(), });

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