Skip to content

Conversation

@aryasaatvik
Copy link

Summary

This PR adds JSON Schema generation for mcp_servers.json using Zod v4 for runtime validation and schema generation.

Changes

New Files

  • src/config-schema.ts - Zod schemas for mcpServers config validation
  • scripts/generate-json-schema.ts - Script to generate JSON Schema using Zod's toJSONSchema()
  • mcp_servers.schema.json - Auto-generated JSON Schema file

Modified Files

  • src/config.ts - Uses Zod safeParse() for runtime validation
  • src/errors.ts - Removed unused configMissingFieldError() helper
  • package.json - Added zod dependency and generate:schema npm script
  • README.md - Added $schema references to config examples
  • mcp_servers.json - Added $schema reference
  • tests/config.test.ts - Updated tests
  • tests/errors.test.ts - Removed configMissingFieldError test
  • tests/integration/cli.test.ts - Fixed macOS path normalization

Key Features

  1. Zod v4 Integration: Uses Zod v4's native toJSONSchema() method
  2. Runtime Validation: Config validated at runtime using Zod's safeParse()
  3. Schema Generation: Run npm run generate:schema to regenerate
  4. IDE Support: Add "$schema": "./mcp_servers.schema.json" for IDE validation

Tests

All 121 tests pass (93 unit + 28 integration)

Breaking Changes

None. Backward-compatible addition.

… mcpServers config validation\n- Add generate-json-schema.ts script using Zod's toJSONSchema()\n- Add mcp_servers.schema.json (auto-generated)\n- Use Zod for runtime config validation\n- Add references to mcp_servers.json and README examples\n- Fix integration test path normalization for macOS\n\nCloses #ISSUE_NUMBER
@philschmid
Copy link
Owner

Hey,

What is the benefit here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants