createVersion
Create a new version of content in Adobe Experience Manager by specifying the content path, with optional labels and comments for tracking changes.
Instructions
Create a new version of content
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| label | No | ||
| comment | No |
Implementation Reference
- src/mcp-server.ts:797-801 (handler)MCP tool handler for 'createVersion': extracts parameters from tool call arguments and invokes AEMConnector.createVersion, formats result as MCP responsecase 'createVersion': { const { path, label, comment } = args as { path: string; label?: string; comment?: string }; const result = await aemConnector.createVersion(path, label, comment); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
- src/mcp-server.ts:527-538 (schema)JSON schema defining input parameters for the createVersion tool: path (required), optional label and commentname: 'createVersion', description: 'Create a new version of content', inputSchema: { type: 'object', properties: { path: { type: 'string' }, label: { type: 'string' }, comment: { type: 'string' } }, required: ['path'], }, },
- Core implementation of createVersion: validates input, checks out node, POSTs form data to AEM's /bin/wcm/versioning/createVersion endpoint with cmd=createVersion, path, optional label/comment; checks in node; constructs and returns standardized success response with version detailsasync createVersion(path: string, label?: string, comment?: string): Promise<CreateVersionResponse> { return safeExecute<CreateVersionResponse>(async () => { if (!isValidContentPath(path)) { throw createAEMError( AEM_ERROR_CODES.INVALID_PARAMETERS, `Invalid content path: ${path}`, { path } ); } try { // Check out the content first await this.checkOutContent(path); // Create version using AEM's versioning API const formData = new URLSearchParams(); formData.append('cmd', 'createVersion'); formData.append('path', path); if (label) { formData.append('label', label); } if (comment) { formData.append('comment', comment); } const response = await this.httpClient.post('/bin/wcm/versioning/createVersion', formData, { headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, }); // Check the content back in await this.checkInContent(path); const versionName = response.data?.versionName || `v${Date.now()}`; this.logger.info(`Created version for path: ${path}`, { versionName, label, comment }); return createSuccessResponse({ path, versionName, label, comment, created: new Date().toISOString(), createdBy: this.config.serviceUser.username }, 'createVersion') as CreateVersionResponse; } catch (error: any) { throw handleAEMHttpError(error, 'createVersion'); } }, 'createVersion'); }
- src/aem-connector-new.ts:277-279 (helper)AEMConnector wrapper method that delegates createVersion call to the specialized VersionOperations instanceasync createVersion(path: string, label?: string, comment?: string) { return this.versionOps.createVersion(path, label, comment); }
- src/mcp-server.ts:578-580 (registration)Registers the listTools handler which returns the full tools array including createVersion tool definition for MCP clients to discover available toolsserver.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });