Skip to main content
Glama

compare_versions

Analyze software versions to determine upgrade requirements and end-of-life status for informed maintenance decisions.

Instructions

Compare versions and get detailed upgrade analysis

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
productYesSoftware product name (e.g., python, nodejs)
versionYesCurrent version being used

Implementation Reference

  • The core handler function that executes the compare_versions tool. It validates input, fetches product cycle data from EOL API, finds current and latest supported versions, performs EOL validation, generates upgrade recommendations, and returns formatted JSON response.
    private async handleCompareVersions(args: CompareVersionsArgs) {
      const { product, version } = args;
    
      // Validate product exists
      if (!this.availableProducts.includes(product)) {
        return {
          content: [{
            type: "text",
            text: `Invalid product: ${product}. Use list_products tool to see available products.`
          }],
          isError: true
        };
      }
    
      try {
        const cycles = await this.getProductDetails(product);
        const currentDate = new Date();
    
        // Validate current version
        const currentCycle = cycles.find(c => c?.cycle?.startsWith(version));
        if (!currentCycle) {
          return {
            content: [{
              type: "text",
              text: `Version ${version} not found for ${product}`
            }],
            isError: true
          };
        }
    
        // Find and validate latest supported version
        const latestSupportedCycle = cycles.find(c => {
          const validation = this.validateVersion(c, currentDate);
          return validation.isValid && validation.isSupported;
        }) || cycles[0];
    
        // Validate both versions
        const currentValidation = this.validateVersion(currentCycle, currentDate);
        const latestValidation = this.validateVersion(latestSupportedCycle, currentDate);
    
        // Cache the query
        this.recentQueries.unshift({
          product,
          version,
          response: [currentCycle, latestSupportedCycle],
          timestamp: currentDate.toISOString()
        });
    
        if (this.recentQueries.length > API_CONFIG.MAX_CACHED_QUERIES) {
          this.recentQueries.pop();
        }
    
        const response = {
          current_date: currentDate.toISOString(),
          validations: {
            current: this.formatVersionValidation(currentCycle, currentValidation),
            latest: this.formatVersionValidation(latestSupportedCycle, latestValidation)
          },
          recommendation: {
            needs_update: !currentValidation.isValid || !currentValidation.isSupported,
            urgency: this.getUpgradeUrgency(currentValidation.daysToEol),
            message: this.getRecommendationMessage(currentValidation)
          }
        };
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify(response, null, 2)
          }]
        };
      } catch (error) {
        if (axios.isAxiosError(error)) {
          return {
            content: [{
              type: "text",
              text: `API error: ${error.response?.data?.message ?? error.message}`
            }],
            isError: true
          };
        }
        throw error;
      }
    }
  • TypeScript interface defining the input arguments for compare_versions tool and the type guard function used to validate arguments before execution.
    export interface CompareVersionsArgs {
      product: string;
      version: string;
    }
    
    export function isValidCompareVersionsArgs(args: any): args is CompareVersionsArgs {
      return (
        typeof args === "object" &&
        args !== null &&
        "product" in args &&
        typeof args.product === "string" &&
        "version" in args &&
        typeof args.version === "string"
      );
    }
  • src/index.ts:343-362 (registration)
    Tool registration in the ListToolsRequestSchema response. Defines the tool's metadata, description, and JSON schema for input validation in MCP protocol.
    {
      name: "compare_versions",
      description: "Compare versions and get detailed upgrade analysis",
      inputSchema: {
        type: "object",
        properties: {
          product: {
            type: "string",
            description: "Software product name (e.g., python, nodejs)",
            examples: ["python", "nodejs"]
          },
          version: {
            type: "string",
            description: "Current version being used",
            examples: ["3.8", "16"]
          }
        },
        required: ["product", "version"]
      }
    },
  • src/index.ts:416-425 (registration)
    Dispatch handler in CallToolRequestSchema that validates arguments using the type guard and invokes the main handleCompareVersions function.
    case "compare_versions": {
      if (!isValidCompareVersionsArgs(args)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          "Invalid version comparison arguments"
        );
      }
    
      return this.handleCompareVersions(args);
    }
  • Helper function used by the handler to validate a version's EOL status, calculate days to EOL, and determine support status.
    private validateVersion(cycle: EOLCycle | undefined, currentDate: Date = new Date()): ValidationResult {
      if (!cycle?.eol) {
        return {
          isValid: false,
          daysToEol: 0,
          isSupported: false,
          validationMessage: `Invalid cycle data for version ${cycle?.cycle ?? 'unknown'}`
        };
      }
    
      const eolDate = new Date(cycle.eol);
      const daysToEol = Math.floor((eolDate.getTime() - currentDate.getTime()) / (1000 * 60 * 60 * 24));
      const isSupported = this.isValueTruthy(cycle.support);
    
      return {
        isValid: daysToEol > 0,
        daysToEol,
        isSupported,
        validationMessage: `Version ${cycle.cycle} EOL date ${cycle.eol} is ${daysToEol > 0 ? 'valid' : 'invalid'}, ${daysToEol > 0 ? '+' : ''}${daysToEol} days from now`
      };
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'compare versions' implies a read-only analysis operation, it doesn't specify whether this requires authentication, has rate limits, returns structured data, or handles errors. The mention of 'detailed upgrade analysis' suggests richer output, but this isn't elaborated.

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 extremely concise—just one sentence with zero wasted words. It's front-loaded with the core purpose and efficiently communicates the tool's function without unnecessary elaboration.

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?

For a tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what 'detailed upgrade analysis' entails, how results are structured, or any behavioral constraints. Given the complexity implied by 'analysis' and lack of structured output documentation, this leaves significant gaps for an agent.

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

Parameters3/5

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

Schema description coverage is 100%, so the input schema already fully documents both parameters (product and version) with descriptions and examples. The description adds no additional parameter semantics beyond what's in the schema, meeting the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the tool's purpose with specific verbs ('compare versions' and 'get detailed upgrade analysis'), making it easy to understand what the tool does. However, it doesn't explicitly distinguish this from sibling tools like 'check_version' or 'get_all_details', which might have overlapping functionality.

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 like 'check_version' or 'check_cve'. There's no mention of prerequisites, appropriate contexts, or exclusions, leaving the agent to guess based on tool names alone.

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/ducthinh993/mcp-server-endoflife'

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