Skip to main content
Glama
Octodet

Advanced Keycloak MCP server

by Octodet

reset-user-password

Reset or set a new password for a user in a specific Keycloak realm, with an option to mark it as temporary.

Instructions

Reset or set a new password for a user in a specific realm

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
realmYesRealm name
userIdYesUser ID
passwordYesNew password
temporaryNoWhether the password is temporary

Implementation Reference

  • MCP tool call handler for 'reset-user-password': validates input with Zod schema, calls KeycloakService.resetUserPassword, and returns success message.
    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." : "."
            }`,
          },
        ],
      };
    }
  • Core implementation in KeycloakService: authenticates, sets realm, and calls Keycloak admin client 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,
        },
      });
    }
  • Zod schema for validating input parameters to the reset-user-password tool.
    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 ListTools response, including name, description, and input schema.
    {
      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"],
      },
    },

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