Skip to main content
Glama
Octodet

Advanced Keycloak MCP server

by Octodet

list-users

Retrieve and display user accounts within a specified Keycloak realm to manage access and review user data.

Instructions

List users in a specific realm

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
realmYesRealm name

Implementation Reference

  • The tool handler for 'list-users' that parses the input arguments using ListUsersSchema, retrieves the list of users from the Keycloak service, and formats the response as a text list of usernames and IDs.
    case "list-users": { const { realm } = ListUsersSchema.parse(args); const users = await keycloakService.listUsers(realm); return { content: [ { type: "text", text: `Users in realm ${realm}:\n${users .map((u) => `- ${u.username} (${u.id})`) .join("\n")}`, }, ], }; }
  • The core implementation in KeycloakService that authenticates the client, sets the realm configuration, and fetches all users using the Keycloak admin client API.
    async listUsers(realm: string) { await this.authenticate(); this.client.setConfig({ realmName: realm }); return await this.client.users.find(); }
  • Zod schema used for runtime validation of the tool's input parameters (requires 'realm' as a string).
    const ListUsersSchema = z.object({ realm: z.string(), });
  • src/index.ts:387-396 (registration)
    Tool registration entry in the listTools handler, defining the name, description, and JSON schema for input validation.
    name: "list-users", description: "List users in a specific realm", inputSchema: { type: "object", properties: { realm: { type: "string", description: "Realm name" }, }, required: ["realm"], }, },

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

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