| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…to number The flag in the schema generation script converts all TypeScript types to JSON Schema . While correct for most fields, NumberSchema's , , and properties must remain type since they define constraints for schemas that may have . Fixes modelcontextprotocol#2698
There was a problem hiding this comment.
Fixes schema generation so NumberSchema.minimum, NumberSchema.maximum, and NumberSchema.default are emitted as JSON Schema "type": "number" (not "integer"), resolving #2698 and ensuring numeric constraints can represent non-integers.
Changes:
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| scripts/generate-schemas.ts | Adds post-processing to correct NumberSchema property types during generation and check paths. |
| schema/draft/schema.json | Updates NumberSchema min/max/default to "number". |
| schema/2025-11-25/schema.json | Updates NumberSchema min/max/default to "number". |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
| let content = readFileSync(schemaPath, 'utf-8'); | ||
| const schema = JSON.parse(content); | ||
|
|
||
| const numberSchema = schema.$defs?.NumberSchema ?? schema.definitions?.NumberSchema; | ||
| if (numberSchema?.properties) { | ||
| for (const prop of ['minimum', 'maximum', 'default']) { | ||
| if (numberSchema.properties[prop]?.type === 'integer') { | ||
| numberSchema.properties[prop].type = 'number'; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| writeFileSync(schemaPath, JSON.stringify(schema, null, 2) + '\n', 'utf-8'); |
| // Fix NumberSchema properties that were incorrectly converted to integer | ||
| const parsedSchema = JSON.parse(expectedSchema); | ||
| const numberSchema = parsedSchema.$defs?.NumberSchema ?? parsedSchema.definitions?.NumberSchema; | ||
| if (numberSchema?.properties) { | ||
| for (const prop of ['minimum', 'maximum', 'default']) { | ||
| if (numberSchema.properties[prop]?.type === 'integer') { | ||
| numberSchema.properties[prop].type = 'number'; | ||
| } | ||
| } | ||
| } | ||
| expectedSchema = JSON.stringify(parsedSchema, null, 2) + '\n'; | ||
|
|
||
| // Compare | ||
| if (existingSchema.trim() !== expectedSchema.trim()) { | ||
| console.error(` ✗ Schema ${version} is out of date!`); |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Fixes #2698
The --defaultNumberType integer flag in scripts/generate-schemas.ts converts all TypeScript number types to JSON Schema integer during schema generation. While this is correct for most fields (request IDs, ports, etc.), it incorrectly converts NumberSchema's minimum, maximum, and default properties to integer type. These fields should be number type because they define constraints for schemas that can have "type": "number".
Changes
scripts/generate-schemas.ts
schema/2025-11-25/schema.json and schema/draft/schema.json
Before
After