Skip to main content
Glama

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
NameRequiredDescriptionDefault
pathYes
labelNo
commentNo

Implementation Reference

  • MCP tool handler for 'createVersion': extracts parameters from tool call arguments and invokes AEMConnector.createVersion, formats result as MCP response
    case '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) }] };
    }
  • JSON schema defining input parameters for the createVersion tool: path (required), optional label and comment
      name: '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 details
    async 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');
    }
  • AEMConnector wrapper method that delegates createVersion call to the specialized VersionOperations instance
    async createVersion(path: string, label?: string, comment?: string) {
      return this.versionOps.createVersion(path, label, comment);
    }
  • Registers the listTools handler which returns the full tools array including createVersion tool definition for MCP clients to discover available tools
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return { tools };
    });

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/indrasishbanerjee/aem-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server