Skip to content

fix: NumberSchema min/max/default should be number, not integer#2710

Open
gsdv wants to merge 1 commit into
modelcontextprotocol:mainfrom
gsdv:fix/number-schema-integer-type
Open

fix: NumberSchema min/max/default should be number, not integer#2710
gsdv wants to merge 1 commit into
modelcontextprotocol:mainfrom
gsdv:fix/number-schema-integer-type

Conversation

@gsdv
Copy link
Copy Markdown

@gsdv gsdv commented May 11, 2026

Fixes #2698

Motivation and Context

In NumberSchema, fields minimum, maximum, and default are declared as number in the TypeScript source, but the generated schema.json outputs them as "type": "integer". This is wrong, as a NumberSchema whose type is "number" must accept non-integer values for its bounds and default.

Root cause: scripts/generate-schemas.ts invokes typescript-json-schema with --defaultNumberType integer, which makes every TS number serialize as JSON integer unless the field opts out. The NumberSchema fields do not have opt-out annotation.

The fix uses the same @TJS-type number JSDoc escape hatch already used elsewhere in the schema (like in ProgressNotification.progress).

How Has This Been Tested?

Ran npm run generate:schema and confirmed the JSON diff is exactly integer to number for the three fields in both draft and 2025-11-25. npm run check:schema passes.

Breaking Changes

No breaking changes, source types are unchanged. The JSON schema is now more permissive, accepting non-integer values for minimum, maximum, and default. The previous rejecting of non-integer values was incorrect.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • [] I have added appropriate error handling
  • [] I have added or updated documentation as needed

Additional context

AI assistance disclosure

I had Claude Code help me confirm the fix was correct.

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.

NumberSchema shows "minimum", "maximum" as integer rather than number

1 participant