list-users
Retrieve and display user details within a specified Keycloak realm using the Advanced Keycloak MCP server. Input the realm name to generate a comprehensive user list.
Instructions
List users in a specific realm
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| realm | Yes | Realm name |
Implementation Reference
- src/index.ts:537-550 (handler)MCP tool handler for 'list-users': validates input with ListUsersSchema, calls KeycloakService.listUsers(realm), formats and returns list of users.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")}`, }, ], }; }
- src/index.ts:467-469 (schema)Zod schema used to validate input parameters for the 'list-users' tool.const ListUsersSchema = z.object({ realm: z.string(), });
- src/index.ts:386-396 (registration)Tool registration in listTools response, including name, description, and inputSchema.{ name: "list-users", description: "List users in a specific realm", inputSchema: { type: "object", properties: { realm: { type: "string", description: "Realm name" }, }, required: ["realm"], }, },
- src/index.ts:151-155 (helper)KeycloakService.listUsers: authenticates, sets realm, and retrieves users via Keycloak admin client API.async listUsers(realm: string) { await this.authenticate(); this.client.setConfig({ realmName: realm }); return await this.client.users.find(); }