list-users
Retrieve all users within a specified Keycloak realm to manage user accounts and access permissions.
Instructions
List users in a specific realm
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| realm | Yes |
Implementation Reference
- src/index.ts:167-182 (handler)The handler function for the 'list-users' tool. It parses the input arguments using ListUsersSchema, configures the Keycloak client for the specified realm, fetches the list of users using kcAdminClient.users.find(), and returns a formatted text response listing the users with their usernames and IDs.case "list-users": { const { realm } = ListUsersSchema.parse(args); kcAdminClient.setConfig({ realmName: realm }); const users = await kcAdminClient.users.find(); return { content: [{ type: "text", text: `Users in realm ${realm}:\n${users.map(u => `- ${u.username} (${u.id})`).join('\n')}` }] }; }
- src/index.ts:39-41 (schema)Zod schema for validating the input parameters of the 'list-users' tool, requiring a 'realm' string.const ListUsersSchema = z.object({ realm: z.string() });
- src/index.ts:83-93 (registration)The tool registration entry for 'list-users' in the listTools response, including name, description, and inputSchema matching the ListUsersSchema.{ name: "list-users", description: "List users in a specific realm", inputSchema: { type: "object", properties: { realm: { type: "string" } }, required: ["realm"] } }