reset-user-password
Reset or set a new password for a user in a specific realm on the Advanced Keycloak MCP server. Specify the realm, user ID, new password, and optional temporary flag.
Instructions
Reset or set a new password for a user in a specific realm
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| password | Yes | New password | |
| realm | Yes | Realm name | |
| temporary | No | Whether the password is temporary | |
| userId | Yes | User ID |
Implementation Reference
- src/index.ts:584-597 (handler)MCP tool handler that validates arguments using Zod schema, invokes the Keycloak service method, and formats a success response.case "reset-user-password": { const params = ResetUserPasswordSchema.parse(args); await keycloakService.resetUserPassword(params); return { content: [ { type: "text", text: `Password ${params.temporary ? "temporarily " : ""}reset successfully for user ${params.userId} in realm ${params.realm}${ params.temporary ? ". User will be required to change password on next login." : "." }`, }, ], }; }
- src/index.ts:282-301 (helper)Core helper method in KeycloakService that handles authentication and executes the Keycloak admin client API call to reset the user's password.async resetUserPassword(params: { realm: string; userId: string; password: string; temporary?: boolean; }) { await this.authenticate(); this.client.setConfig({ realmName: params.realm }); await this.client.users.resetPassword({ id: params.userId, realm: params.realm, credential: { type: "password", value: params.password, temporary: params.temporary || false, }, }); } }
- src/index.ts:484-489 (schema)Zod schema used for runtime validation of input parameters in the tool handler.const ResetUserPasswordSchema = z.object({ realm: z.string(), userId: z.string(), password: z.string(), temporary: z.boolean().default(false), });
- src/index.ts:424-437 (registration)Tool registration in the listTools response, defining name, description, and JSON schema for inputs.{ name: "reset-user-password", description: "Reset or set a new password for a user in a specific realm", inputSchema: { type: "object", properties: { realm: { type: "string", description: "Realm name" }, userId: { type: "string", description: "User ID" }, password: { type: "string", description: "New password" }, temporary: { type: "boolean", description: "Whether the password is temporary", default: false }, }, required: ["realm", "userId", "password"], }, },