restoreVersion
Restore content to a specific version in Adobe Experience Manager by providing the content path and version name.
Instructions
Restore content to a specific version
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| versionName | Yes |
Implementation Reference
- src/mcp-server.ts:539-550 (registration)MCP tool registration for 'restoreVersion' including schema definition{ name: 'restoreVersion', description: 'Restore content to a specific version', inputSchema: { type: 'object', properties: { path: { type: 'string' }, versionName: { type: 'string' } }, required: ['path', 'versionName'], }, },
- src/mcp-server.ts:802-806 (handler)MCP server CallToolRequestSchema handler that calls AEMConnector.restoreVersion with extracted parameterscase 'restoreVersion': { const { path, versionName } = args as { path: string; versionName: string }; const result = await aemConnector.restoreVersion(path, versionName); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
- src/aem-connector-new.ts:281-283 (handler)AEMConnector method that delegates restoreVersion call to VersionOperations moduleasync restoreVersion(path: string, versionName: string) { return this.versionOps.restoreVersion(path, versionName); }
- Core implementation of restoreVersion: validates inputs, fetches current version, executes POST to AEM /bin/wcm/versioning/restoreVersion, logs action, returns formatted responseasync restoreVersion(path: string, versionName: string): Promise<RestoreVersionResponse> { return safeExecute<RestoreVersionResponse>(async () => { if (!isValidContentPath(path)) { throw createAEMError( AEM_ERROR_CODES.INVALID_PARAMETERS, `Invalid content path: ${path}`, { path } ); } if (!versionName || typeof versionName !== 'string') { throw createAEMError( AEM_ERROR_CODES.INVALID_PARAMETERS, 'Version name is required', { versionName } ); } try { // Get current version before restore const versionHistory = await this.getVersionHistory(path); const currentVersion = versionHistory.data.baseVersion; // Restore version using AEM's versioning API const formData = new URLSearchParams(); formData.append('cmd', 'restoreVersion'); formData.append('path', path); formData.append('version', versionName); await this.httpClient.post('/bin/wcm/versioning/restoreVersion', formData, { headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, }); this.logger.info(`Restored version for path: ${path}`, { versionName, previousVersion: currentVersion }); return createSuccessResponse({ path, restoredVersion: versionName, previousVersion: currentVersion, restoredAt: new Date().toISOString(), restoredBy: this.config.serviceUser.username }, 'restoreVersion') as RestoreVersionResponse; } catch (error: any) { throw handleAEMHttpError(error, 'restoreVersion'); } }, 'restoreVersion'); }