create-user
Add a new user to a Keycloak realm by providing required details like username, email, and name.
Instructions
Create a new user in a specific realm
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| realm | Yes | ||
| username | Yes | ||
| Yes | |||
| firstName | Yes | ||
| lastName | Yes |
Implementation Reference
- src/index.ts:112-134 (handler)Implements the 'create-user' tool handler: parses arguments with CreateUserSchema, sets Keycloak realm config, creates user via admin client, returns success with user ID.case "create-user": { const { realm, username, email, firstName, lastName } = CreateUserSchema.parse(args); kcAdminClient.setConfig({ realmName: realm }); const user = await kcAdminClient.users.create({ realm, username, email, firstName, lastName, enabled: true }); return { content: [{ type: "text", text: `User created successfully. User ID: ${user.id}` }] }; }
- src/index.ts:26-32 (schema)Zod schema defining input validation for create-user tool parameters.const CreateUserSchema = z.object({ realm: z.string(), username: z.string(), email: z.string().email(), firstName: z.string(), lastName: z.string() });
- src/index.ts:47-61 (registration)Tool registration in the listTools response, defining name, description, and input schema for 'create-user'.{ name: "create-user", description: "Create a new user in a specific realm", inputSchema: { type: "object", properties: { realm: { type: "string" }, username: { type: "string" }, email: { type: "string", format: "email" }, firstName: { type: "string" }, lastName: { type: "string" } }, required: ["realm", "username", "email", "firstName", "lastName"] } },