replicateAndPublish
Distribute content to multiple locales by replicating and publishing component data with localized overrides in Adobe Experience Manager.
Instructions
Replicate and publish content to selected locales
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selectedLocales | Yes | ||
| componentData | Yes | ||
| localizedOverrides | No |
Implementation Reference
- Core implementation of the replicateAndPublish tool logic. Handles multi-locale replication to AEM, supports MSM (Multi-Site Manager) structures, performs content activation via replication APIs, includes comprehensive error handling with optional rollback on failures.
async replicateAndPublish( selectedLocales: string[], componentData: unknown, localizedOverrides?: unknown ): Promise<ReplicateResponse> { return safeExecute<ReplicateResponse>(async () => { if (!selectedLocales || selectedLocales.length === 0) { throw createAEMError( AEM_ERROR_CODES.INVALID_PARAMETERS, 'selectedLocales array is required and cannot be empty', { selectedLocales } ); } const results: Array<{ locale: string; success: boolean; message: string; path?: string; error?: string; replicationId?: string; }> = []; const successfulReplications: string[] = []; let hasFailures = false; for (const locale of selectedLocales) { try { this.logger.info(`Starting replication to locale: ${locale}`, { componentData: typeof componentData, hasOverrides: !!localizedOverrides }); // Step 1: Validate locale path exists const localePath = this.validateAndBuildLocalePath(locale); // Step 2: Check if content is part of MSM structure const isMSMContent = await this.checkMSMStructure(localePath); let replicationResult: any; if (isMSMContent) { // Step 3a: Use MSM APIs for live copy updates replicationResult = await this.handleMSMReplication( localePath, componentData, localizedOverrides ); } else { // Step 3b: Standard replication process replicationResult = await this.handleStandardReplication( localePath, componentData, localizedOverrides ); } // Step 4: Activate content in the target locale await this.activateContentInLocale(localePath); results.push({ locale, success: true, message: `Content replicated and activated successfully to ${locale}`, path: localePath, replicationId: replicationResult.replicationId }); successfulReplications.push(locale); this.logger.info(`Content replicated successfully to locale: ${locale}`, { path: localePath, replicationId: replicationResult.replicationId }); } catch (error: any) { hasFailures = true; results.push({ locale, success: false, message: `Failed to replicate to ${locale}: ${error.message}`, error: error.message }); this.logger.error(`Failed to replicate to locale: ${locale}`, { error: error.message, stack: error.stack }); // If we have a strict policy, rollback successful replications if (this.config.strictReplication) { await this.rollbackSuccessfulReplications(successfulReplications); } } } return createSuccessResponse({ message: hasFailures ? `Replication completed with errors. ${successfulReplications.length}/${selectedLocales.length} locales successful.` : 'All replications completed successfully', selectedLocales, successfulLocales: successfulReplications, failedLocales: results.filter(r => !r.success).map(r => r.locale), componentData, localizedOverrides, results, success: !hasFailures, summary: { total: selectedLocales.length, successful: successfulReplications.length, failed: selectedLocales.length - successfulReplications.length } }, 'replicateAndPublish') as ReplicateResponse; }, 'replicateAndPublish'); } - src/mcp-server.ts:630-633 (handler)MCP server CallToolRequest handler for 'replicateAndPublish' tool. Receives MCP tool call parameters and delegates execution to AEMConnector.replicateAndPublish, formats response as MCP content.
case 'replicateAndPublish': { const result = await aemConnector.replicateAndPublish(args.selectedLocales, args.componentData, args.localizedOverrides); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } - src/mcp-server.ts:103-115 (schema)JSON schema definition for the replicateAndPublish MCP tool input parameters, used for tool registration and validation.
{ name: 'replicateAndPublish', description: 'Replicate and publish content to selected locales', inputSchema: { type: 'object', properties: { selectedLocales: { type: 'array', items: { type: 'string' } }, componentData: { type: 'object' }, localizedOverrides: { type: 'object' }, }, required: ['selectedLocales', 'componentData'], }, }, - src/mcp-server.ts:578-580 (registration)MCP server registration of tool list handler. Returns the complete list of available tools including replicateAndPublish schema for ListTools requests.
server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; }); - src/aem-connector-new.ts:188-190 (helper)Delegation method in AEMConnector that routes replicateAndPublish calls to the ReplicationOperations module.
async replicateAndPublish(selectedLocales: any, componentData: any, localizedOverrides?: any) { return this.replicationOps.replicateAndPublish(selectedLocales, componentData, localizedOverrides); }