Add range validation for MCP::Annotations#priority per MCP specification#3
Closed
yuki3738 wants to merge 3 commits into
Closed
Add range validation for MCP::Annotations#priority per MCP specification#3yuki3738 wants to merge 3 commits into
MCP::Annotations#priority per MCP specification#3yuki3738 wants to merge 3 commits into
Conversation
Require rubocop-minitest 0.39.0 or newer so Minitest/AssertEmptyLiteral uses its newer default disabled state.
…eanup-existing-offenses chore: require rubocop-minitest 0.39
…ation ## Motivation and Context The MCP specification constrains `Annotations.priority` to the 0–1 range (`@minimum 0`, `@maximum 1`), but the Ruby SDK accepts any value. The other official SDKs already enforce this (TypeScript, Python, and PHP). This follows the existing pattern in `MCP::Icon`, which validates its constrained `theme` value in the constructor and raises `ArgumentError`. ## How Has This Been Tested? Added tests in `test/mcp/annotations_test.rb`: - valid `priority` at the lower (0) and upper (1) bounds is accepted - out-of-range `priority` (above 1, below 0) raises `ArgumentError` The full unit suite and RuboCop pass locally. ## Breaking Changes Strictly speaking yes: a caller that currently passes an out-of-range `priority` (e.g. `priority: 99`) will now get an `ArgumentError`. Such values already violate the MCP specification, and `nil` / in-range values are unaffected.
25f0560 to
c588582
Compare
Owner
Author
|
Practice/self-review complete. The real contribution is upstream at modelcontextprotocol#410. |
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.
Motivation and Context
The MCP specification constrains
Annotations.priorityto the 0–1 range (@minimum 0,@maximum 1) (spec), but the Ruby SDK accepts any value. The other official SDKs already enforce this (TypeScript, Python, and PHP).This follows the existing pattern in
MCP::Icon, which validates its constrainedthemevalue in the constructor and raisesArgumentError.How Has This Been Tested?
Added tests in
test/mcp/annotations_test.rb:priorityat the lower (0) and upper (1) bounds is acceptedpriority(above 1, below 0) raisesArgumentErrorThe full unit suite and RuboCop pass locally.
Breaking Changes
Strictly speaking yes: a caller that currently passes an out-of-range
priority(e.g.priority: 99) will now get anArgumentError. Such values already violate the MCP specification, andnil/ in-range values are unaffected.Types of changes
Checklist