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:
-
Primary Strategy: Search for
package.json
in multiple locations:- Current directory
- Parent directory
- Grandparent directory
- Process working directory
-
Environment Strategy: Use
process.env.npm_package_version
when available (during npm scripts) -
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