Skip to content

Add annotations field to MCP::Resource and MCP::ResourceTemplate per MCP specification#2

Closed
yuki3738 wants to merge 1 commit into
mainfrom
add_annotations_field_to_resource
Closed

Add annotations field to MCP::Resource and MCP::ResourceTemplate per MCP specification#2
yuki3738 wants to merge 1 commit into
mainfrom
add_annotations_field_to_resource

Conversation

@yuki3738

@yuki3738 yuki3738 commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Note: This is a practice / self-review PR inside my own fork. Not the upstream contribution.

Motivation and Context

The MCP specification defines an optional annotations field on both the Resource and ResourceTemplate types (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::Annotations class already exists; this PR 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.

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

@LuuOW LuuOW left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technical audit: Architecture and implementation patterns verified for consistency with MCP ecosystem standards.

@yuki3738 yuki3738 force-pushed the add_annotations_field_to_resource branch from 4868930 to 6cba459 Compare June 14, 2026 06:56
…` 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.
@yuki3738 yuki3738 force-pushed the add_annotations_field_to_resource branch from 6cba459 to 64219be Compare June 14, 2026 07:06
@yuki3738

Copy link
Copy Markdown
Owner Author

Practice/self-review complete. The real contribution is upstream at modelcontextprotocol#403.

@yuki3738 yuki3738 closed this Jun 14, 2026
@yuki3738 yuki3738 deleted the add_annotations_field_to_resource branch June 14, 2026 15:57
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