Set Default Theme
setDefaultThemeAssign a theme as the default for a realm to apply it to all authentication experiences.
Instructions
Set a theme as the default for a realm in PingOne AIC
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| realm | Yes | Realm name | |
| themeIdentifier | Yes | Theme ID or name |
Implementation Reference
- Main handler for the setDefaultTheme tool. Fetches theme configuration from PingOne AIC, finds the theme by ID/name, sets all themes' isDefault to false except the target, and PUTs the updated config back.
export const setDefaultThemeTool = { name: 'setDefaultTheme', title: 'Set Default Theme', description: 'Set a theme as the default for a realm in PingOne AIC', scopes: SCOPES, annotations: { destructiveHint: false, idempotentHint: true, openWorldHint: true }, inputSchema: { realm: z.enum(REALMS).describe('Realm name'), themeIdentifier: safePathSegmentSchema.describe('Theme ID or name') }, async toolFunction({ realm, themeIdentifier }: { realm: string; themeIdentifier: string }) { try { // Get the current theme configuration const configUrl = `https://${aicBaseUrl}/openidm/config/ui/themerealm`; const { data: config } = await makeAuthenticatedRequest(configUrl, SCOPES); // Validate config structure if (!config || !(config as any).realm || !(config as any).realm[realm]) { return createToolResponse(`Invalid theme configuration structure for realm "${realm}"`); } const realmThemes = (config as any).realm[realm]; // Find the theme by ID or name const themeIndex = realmThemes.findIndex((t: any) => t._id === themeIdentifier || t.name === themeIdentifier); if (themeIndex === -1) { return createToolResponse(`Theme not found: "${themeIdentifier}" in realm "${realm}"`); } const targetTheme = realmThemes[themeIndex]; const themeName = targetTheme.name; const themeId = targetTheme._id; // Check if it's already the default if (targetTheme.isDefault === true) { return createToolResponse(`Theme "${themeName}" is already the default theme for realm "${realm}"`); } // Set all themes to isDefault: false, then set target to true const updatedThemes = realmThemes.map((theme: any, index: number) => ({ ...theme, isDefault: index === themeIndex })); // Update the config const updatedConfig = { ...config, realm: { ...(config as any).realm, [realm]: updatedThemes } }; // PUT the updated configuration back const { response } = await makeAuthenticatedRequest(configUrl, SCOPES, { method: 'PUT', body: JSON.stringify(updatedConfig) }); const successMessage = `Set theme "${themeName}" (${themeId}) as default for realm "${realm}"`; return createToolResponse( formatSuccess({ _id: themeId, name: themeName, isDefault: true, message: successMessage }, response) ); } catch (error: any) { return createToolResponse(`Failed to set default theme in realm "${realm}": ${error.message}`); } } }; - Input schema for setDefaultTheme: requires a realm (alpha or bravo) and a themeIdentifier (ID or name, validated for safe URL path usage).
inputSchema: { realm: z.enum(REALMS).describe('Realm name'), themeIdentifier: safePathSegmentSchema.describe('Theme ID or name') }, - src/tools/themes/index.ts:8-8 (registration)Re-exports the setDefaultThemeTool from the themes barrel index file.
export { setDefaultThemeTool } from './setDefaultTheme.js'; - Schema documentation noting isDefault is controlled via setDefaultTheme tool.
systemControlledFields: { _id: 'Auto-generated UUID (do not provide on create)', isDefault: 'Controlled via setDefaultTheme tool (always false on create)' },