feat: export versioned schemas in package.json#138
Merged
Conversation
Add exports for versioned schemas to allow consumers to import:
- ./schemas: All versioned schemas (v0_1, v0_2, v0_3, latest)
- ./schemas/*: Specific schema versions (./schemas/0.1, ./schemas/any, etc.)
- ./schemas-loose: Loose validation schemas
This enables cleaner imports like:
import { McpbManifestSchema } from '@anthropic-ai/mcpb/schemas/any'
import * as v0_2 from '@anthropic-ai/mcpb/schemas/0.2'
import * as schemas from '@anthropic-ai/mcpb/schemas'
Changed McpbManifest type from a single version to a discriminated union of all historical manifest versions (0.1, 0.2, 0.3). This allows the type system to properly handle manifests from any version while maintaining type safety through the manifest_version/dxt_version discriminator field. Benefits: - Type-safe handling of multiple manifest versions - TypeScript can narrow types based on version field - No need for type assertions when working with versioned manifests - Maintains backward compatibility with all historical versions
Updated build script to generate JSON schemas for all historical manifest versions (v0.1, v0.2, v0.3) in addition to the latest version. Changes: - Generate mcpb-manifest-v0.1.schema.json - Generate mcpb-manifest-v0.2.schema.json - Generate mcpb-manifest-v0.3.schema.json - Generate mcpb-manifest-latest.schema.json - Keep mcpb-manifest.schema.json as alias for latest - All schemas generated to both dist/ and schemas/ directories - Added exports in package.json for all versioned schemas Benefits: - Tools can validate against specific manifest versions - Backwards compatibility for all historical versions - Latest schema always available at predictable path - JSON schema files match the Zod schema versions Usage: import manifestSchema from '@anthropic-ai/mcpb/mcpb-manifest-v0.2.schema.json' import latestSchema from '@anthropic-ai/mcpb/mcpb-manifest-latest.schema.json'
Remove the generic mcpb-manifest.schema.json export from package.json in favor of explicit versioned exports. Changes: - Removed ./mcpb-manifest.schema.json from package exports - Stop generating mcpb-manifest.schema.json in dist/ - Keep mcpb-manifest.schema.json in schemas/ for backward compatibility Consumers should now use: - mcpb-manifest-latest.schema.json (for latest version) - mcpb-manifest-v0.1.schema.json (for specific version) - etc. This makes versioning explicit and prevents ambiguity about which schema version is being used.
- Remove unused McpbManifestSchema import from types.ts - Run prettier on modified files
This reverts commit 48232bf.
This reverts commit ae3d961.
Reverted the discriminated union type change. McpbManifest now uses the latest schema as before. Consumers can use versioned schemas directly if they need to validate specific versions.
Removed the non-versioned mcpb-manifest.schema.json from schemas/ directory. All schemas are now explicitly versioned. Available schemas: - mcpb-manifest-v0.1.schema.json - mcpb-manifest-v0.2.schema.json - mcpb-manifest-v0.3.schema.json - mcpb-manifest-latest.schema.json Consumers should use -latest or specific version to be explicit about which schema version they're validating against.
MarshallOfSound
approved these changes
Oct 30, 2025
Contributor
MarshallOfSound
left a comment
There was a problem hiding this comment.
Approving for now, we should have a script that ensures the JSON files haven't drifted tho (ez follow up)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add exports for versioned schemas (both Zod and JSON Schema) to allow consumers to import schemas cleanly. Bump version to 1.1.3.
All schema exports are now explicitly versioned with no legacy non-versioned files. Added a union schema (
any) that validates manifests from any supported version.Changes
1. Package Exports
Added export paths for:
Zod Schemas:
./schemas- All versioned Zod schemas (v0_1, v0_2, v0_3, latest, any)./schemas/any- Union schema that accepts any version (v0.1, v0.2, v0.3)./schemas/*- Wildcard export for specific schema files (e.g.,./schemas/0.2)./schemas-loose- Loose validation schemasJSON Schemas (all explicitly versioned):
./mcpb-manifest-v0.1.schema.json- v0.1 JSON Schema./mcpb-manifest-v0.2.schema.json- v0.2 JSON Schema./mcpb-manifest-v0.3.schema.json- v0.3 JSON Schema./mcpb-manifest-latest.schema.json- Latest version JSON Schema2. Union Schema (any)
Created
src/schemas/any.ts:This schema accepts and validates manifests from any supported version (0.1, 0.2, 0.3).
3. JSON Schema Generation
Updated build script to generate JSON schemas for all versions:
dist/andschemas/directoriesmcpb-manifest.schema.json(all schemas now explicitly versioned)4. Version Bump
Usage Examples
Zod Schema Imports
Import union schema (recommended for validating any version):
Import specific version:
Import all versions as namespace:
Import latest:
JSON Schema Imports
Before
Consumers had to reach into dist folder:
After
Clean, properly exported imports with explicit versioning:
Files Structure
dist/ (npm package distribution):
schemas/any.js- Union of all versions (NEW)schemas/0.1.js,0.2.js,0.3.js- Specific versionsschemas/latest.js- Latest versionschemas/index.js- All exportsmcpb-manifest-v0.1.schema.jsonmcpb-manifest-v0.2.schema.jsonmcpb-manifest-v0.3.schema.jsonmcpb-manifest-latest.schema.jsonmcpb-signature-info.schema.jsonschemas/ (source schemas, included in package):
mcpb-manifest-v0.1.schema.jsonmcpb-manifest-v0.2.schema.jsonmcpb-manifest-v0.3.schema.jsonmcpb-manifest-latest.schema.jsonTesting
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com