Skip to main content

Version Management

Overviewโ€‹

The MCP ADR Analysis Server uses a robust version management system that automatically reads the version from package.json and provides future-proof fallback handling.

How It Worksโ€‹

Version Resolution Strategyโ€‹

The getPackageVersion() function uses multiple strategies to determine the version:

  1. Primary Strategy: Search for package.json in multiple locations:

    • Current directory
    • Parent directory
    • Grandparent directory
    • Process working directory
  2. Environment Strategy: Use process.env.npm_package_version when available (during npm scripts)

  3. Generic Fallback: Use 'unknown' instead of hardcoded version numbers

Future-Proof Designโ€‹

The version system is designed to be future-proof:

  • โœ… No hardcoded version numbers in fallback logic
  • โœ… Generic fallback that doesn't need updates
  • โœ… Automatic version detection from package.json
  • โœ… Comprehensive test coverage for version scenarios

Previous Issueโ€‹

Before this improvement:

  • Fallback versions were hardcoded (e.g., '2.0.2', '2.0.15')
  • Each version update required manual code changes
  • Risk of version mismatch between package.json and fallback values

Current Solutionโ€‹

After the improvement:

  • Fallback uses generic 'unknown' value
  • No code changes needed when package.json version updates
  • Multiple strategies ensure version is found in most scenarios
  • Clear documentation prevents future hardcoding

Usageโ€‹

# Check version
npx mcp-adr-analysis-server --version

# Example output:
# MCP ADR Analysis Server v2.0.15

Testingโ€‹

The version system includes comprehensive tests:

npm test -- tests/version.test.ts

Tests verify:

  • Correct version reading from package.json
  • Generic fallback behavior
  • Future-proof implementation (no hardcoded version numbers)

Maintenanceโ€‹

When updating the package version:

  1. Update package.json version field โœ…
  2. No code changes needed โœ…
  3. Version command automatically shows new version โœ…

This design eliminates the need for manual code updates when the version changes.