Commit 400cfa6
feat: add library-based ts-to-zod schema generation
Add auto-generated Zod schemas from spec.types.ts using ts-to-zod as a library,
with post-processing for SDK compatibility.
## What's New
- `src/generated/spec.schemas.ts` - 145 auto-generated Zod schemas
- `src/generated/index.ts` - Public API with explicit exports by name
- `test/generated/spec.schemas.compare.test.ts` - 97 tests verifying equivalence
- `scripts/generate-schemas.ts` - Library-based generator with post-processing
## Post-Processing
The generator applies several transformations for SDK compatibility:
1. **Zod v4 import** - `"zod"` → `"zod/v4"`
2. **Index signatures** - `z.record().and(z.object())` → `z.looseObject()`
3. **typeof expressions** - `jsonrpc: z.any()` → `z.literal("2.0")`
4. **SDK hierarchy** - Notifications/Requests extend `NotificationSchema`/`RequestSchema`
5. **Integer refinements** - `ProgressTokenSchema`, `RequestIdSchema` use `.int()`
## Usage
```typescript
import { ProgressTokenSchema } from '@modelcontextprotocol/sdk/generated';
```
## Design
- **types.ts unchanged** - Full refactor to thin re-export layer deferred
- **Explicit exports** - Each schema/type listed by name for legibility
- **No description duplication** - spec.types.ts kept clean (no @description injection)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 67d79d4 commit 400cfa6
File tree
7 files changed
+5319
-15
lines changed- scripts
- src/generated
- test/generated
7 files changed
+5319
-15
lines changed
0 commit comments