Add annotations field to MCP::Resource and MCP::ResourceTemplate per MCP specification#403
Merged
koic merged 1 commit intoJun 14, 2026
Conversation
…` per MCP specification ## Motivation and Context The MCP specification defines an optional `annotations` field on both the `Resource` and `ResourceTemplate` types, but the Ruby SDK is the only official SDK that does not wire it up — TypeScript, Python, and PHP all implement it. https://modelcontextprotocol.io/specification/2025-11-25/server/resources#annotations The `MCP::Annotations` class already exists; this commit connects it. The field accepts an `MCP::Annotations` instance rather than a raw hash, for consistency with other typed fields and to get `lastModified` key normalization for free. ## How Has This Been Tested? Added tests in `test/mcp/resource_test.rb` and `test/mcp/resource_template_test.rb`: - `#to_h` omits `annotations` when nil - `#to_h` includes `annotations` when present (also asserting that `last_modified` is serialized as `lastModified`) The full unit suite and RuboCop pass locally. ## Breaking Changes None. `annotations:` is a new optional keyword argument defaulting to `nil`, and it is omitted from `#to_h` output when not set.
9 tasks
koic
approved these changes
Jun 14, 2026
Member
|
Thanks! |
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 defines an optional
annotationsfield on both theResourceandResourceTemplatetypes (spec), but the Ruby SDK is the only official SDK that does not wire it up — TypeScript, Python, and PHP all implement it.The
MCP::Annotationsclass already exists; this PR connects it. The field accepts anMCP::Annotationsinstance rather than a raw hash, for consistency with other typed fields and to getlastModifiedkey normalization for free.How Has This Been Tested?
Added tests in
test/mcp/resource_test.rbandtest/mcp/resource_template_test.rb:#to_homitsannotationswhen nil#to_hincludesannotationswhen present (also asserting thatlast_modifiedis serialized aslastModified)The full unit suite and RuboCop pass locally.
Breaking Changes
None.
annotations:is a new optional keyword argument defaulting tonil, and it is omitted from#to_houtput when not set.Types of changes
Checklist