fix: add missing zod dependency to template package.json (closes #19)
Summary
Fixes GitLab issue #19 (closed) by adding the missing zod
dependency to the generated MCP server template. This resolves runtime errors when generated projects attempt to use Zod validation.
Problem
The template included zod-to-json-schema
as a dependency but was missing the peer dependency zod
itself, causing:
- Runtime errors in generated projects:
Cannot find module 'zod'
- Generated MCP servers failing to build/run without manual dependency fixes
- Poor developer experience with template not working out-of-the-box
Solution
- Added
"zod": "^3.23.8"
to dependencies intemplates/package.json
- Maintains compatibility with existing
zod-to-json-schema: ^3.23.5
- Enables immediate use of Zod schemas as intended by template design
Changes Made
Core Fix
- templates/package.json: Added zod dependency to enable schema validation
Test Coverage
-
tests/zod-dependency.test.ts: Comprehensive TDD test suite (7 tests)
- Template package.json validation tests
- Dependency compatibility validation
- Template file structure verification
- Dependency specification correctness
Testing
✅
Test Results - All 17 tests pass (7 new + 10 existing)
- TDD approach: wrote failing tests first, then implemented fix
- Core functionality validated through multiple test scenarios
✅
Manual Validation - Template now includes both
zod
andzod-to-json-schema
dependencies - Generated projects will have working Zod schema validation
- No breaking changes to existing template functionality
Impact
❌
Before (Broken) {
"dependencies": {
"@modelcontextprotocol/sdk": "1.0.1",
"dotenv": "^17.2.1",
"zod-to-json-schema": "^3.23.5"
}
}
→ Runtime error: Cannot find module 'zod'
✅
After (Working) {
"dependencies": {
"@modelcontextprotocol/sdk": "1.0.1",
"dotenv": "^17.2.1",
"zod": "^3.23.8",
"zod-to-json-schema": "^3.23.5"
}
}
→ Generated projects work out-of-the-box
Compatibility
-
✅ Compatible with existing zod-to-json-schema version -
✅ No breaking changes to template structure -
✅ Maintains all existing functionality -
✅ Uses semver-compatible version ranges
Closes #19 (closed)