Skip to main content
Glama

compareVersions

Compare two versions of content in Adobe Experience Manager to identify differences and track changes.

Instructions

Compare two versions of content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
version1Yes
version2Yes

Implementation Reference

  • Core handler function that fetches two versions from AEM via HTTP, compares their properties recursively, computes difference summary, and returns structured response with added/removed/modified changes.
    async compareVersions(path: string, version1: string, version2: string): Promise<CompareVersionsResponse> {
      return safeExecute<CompareVersionsResponse>(async () => {
        if (!isValidContentPath(path)) {
          throw createAEMError(
            AEM_ERROR_CODES.INVALID_PARAMETERS,
            `Invalid content path: ${path}`,
            { path }
          );
        }
    
        if (!version1 || !version2 || version1 === version2) {
          throw createAEMError(
            AEM_ERROR_CODES.INVALID_PARAMETERS,
            'Two different version names are required for comparison',
            { version1, version2 }
          );
        }
    
        try {
          // Get both versions
          const version1Response = await this.httpClient.get(`${path}.version.${version1}.json`, {
            params: { ':depth': '2' }
          });
    
          const version2Response = await this.httpClient.get(`${path}.version.${version2}.json`, {
            params: { ':depth': '2' }
          });
    
          // Compare the versions
          const differences = this.compareVersionData(
            version1Response.data,
            version2Response.data
          );
    
          const summary = {
            added: differences.filter(d => d.type === 'added').length,
            removed: differences.filter(d => d.type === 'removed').length,
            modified: differences.filter(d => d.type === 'modified').length
          };
    
          this.logger.info(`Compared versions for path: ${path}`, {
            version1,
            version2,
            differencesCount: differences.length,
            summary
          });
    
          return createSuccessResponse({
            path,
            version1,
            version2,
            differences,
            summary
          }, 'compareVersions') as CompareVersionsResponse;
    
        } catch (error: any) {
          throw handleAEMHttpError(error, 'compareVersions');
        }
      }, 'compareVersions');
    }
  • MCP tool registration including name, description, and input schema definition.
    {
      name: 'compareVersions',
      description: 'Compare two versions of content',
      inputSchema: {
        type: 'object',
        properties: {
          path: { type: 'string' },
          version1: { type: 'string' },
          version2: { type: 'string' }
        },
        required: ['path', 'version1', 'version2'],
      },
    },
  • Top-level MCP server handler that extracts parameters and delegates to AEMConnector.compareVersions.
    case 'compareVersions': {
      const { path, version1, version2 } = args as { path: string; version1: string; version2: string };
      const result = await aemConnector.compareVersions(path, version1, version2);
      return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
    }
  • Type definition for the output response structure including differences array and summary counts.
    export interface CompareVersionsResponse {
      success: boolean;
      operation: string;
      timestamp: string;
      data: {
        path: string;
        version1: string;
        version2: string;
        differences: Array<{
          property: string;
          type: 'added' | 'removed' | 'modified';
          oldValue?: unknown;
          newValue?: unknown;
        }>;
        summary: {
          added: number;
          removed: number;
          modified: number;
        };
      };
    }
  • Recursive helper function that computes property-level differences between two version objects, supporting nested properties via prefix.
    private compareVersionData(data1: any, data2: any, prefix = ''): Array<{
      property: string;
      type: 'added' | 'removed' | 'modified';
      oldValue?: unknown;
      newValue?: unknown;
    }> {
      const differences: Array<{
        property: string;
        type: 'added' | 'removed' | 'modified';
        oldValue?: unknown;
        newValue?: unknown;
      }> = [];
    
      const keys1 = new Set(Object.keys(data1 || {}));
      const keys2 = new Set(Object.keys(data2 || {}));
    
      // Check for added and modified properties
      for (const key of keys2) {
        const fullKey = prefix ? `${prefix}.${key}` : key;
        
        if (!keys1.has(key)) {
          differences.push({
            property: fullKey,
            type: 'added',
            newValue: data2[key]
          });
        } else if (JSON.stringify(data1[key]) !== JSON.stringify(data2[key])) {
          differences.push({
            property: fullKey,
            type: 'modified',
            oldValue: data1[key],
            newValue: data2[key]
          });
        }
      }
    
      // Check for removed properties
      for (const key of keys1) {
        if (!keys2.has(key)) {
          const fullKey = prefix ? `${prefix}.${key}` : key;
          differences.push({
            property: fullKey,
            type: 'removed',
            oldValue: data1[key]
          });
        }
      }
    
      return differences;
    }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states the basic function ('compare') without detailing what the comparison entails (e.g., returns differences, metadata, or a visual output), whether it's read-only or has side effects, or any constraints like rate limits or authentication needs. This leaves critical behavioral traits unspecified, making it inadequate for safe and effective use.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence ('Compare two versions of content') that is front-loaded and wastes no words. It directly conveys the core purpose without unnecessary elaboration, making it efficient and easy to parse for an agent.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a comparison tool with 3 parameters, no annotations, no output schema, and low schema coverage, the description is incomplete. It fails to explain the comparison output, parameter semantics, behavioral traits, or usage context. While conciseness is good, the description lacks the necessary details to compensate for the missing structured data, leaving gaps in understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 3 parameters with 0% description coverage, so the schema provides no semantic information. The description does not explain what 'path', 'version1', or 'version2' represent (e.g., file paths, version IDs, timestamps), their formats, or how they relate to the content being compared. This lack of parameter meaning beyond the schema's basic types significantly hinders correct invocation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Compare two versions of content' clearly states the action (compare) and target (versions of content), avoiding tautology with the tool name. However, it lacks specificity about what 'content' refers to (e.g., pages, assets, components) and how the comparison is performed (e.g., diff, side-by-side view), making it somewhat vague. It does not distinguish this tool from potential siblings like 'getVersionHistory' or 'restoreVersion', which reduces its clarity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It does not mention prerequisites (e.g., needing existing versions), exclusions (e.g., not for comparing non-versioned content), or related tools like 'getVersionHistory' for listing versions first. Without such context, an agent must infer usage from the tool name alone, which is insufficient for optimal selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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