Repository navigation
Conversation
yuki3738
force-pushed
the
add_content_resource_link
branch
3 times, most recently
from
November 22, 2026 15:48
1bb6b7e to
577f3f8
Compare
## Motivation and Context The MCP spec defines a resource link content type (since 2025-06-18) that lets a tool return a link to a resource instead of its contents, but the SDK had no corresponding class. `MCP::Content` covered the other four members of the specification's `ContentBlock` (text, image, audio, and embedded resource) and had no helper for building a resource link. Add `Content::ResourceLink`, which wraps a resource object and serializes it via `to_h`, as `Content::EmbeddedResource` (modelcontextprotocol#244) does for resource contents. In the specification, `ResourceLink` extends `Resource` with `type: "resource_link"`, so the link is the resource's own `to_h` with that `type` added and carries the resource's `title`, `icons`, `annotations`, `size`, and `_meta`. It accepts a resource built with `MCP::Resource.new` and a class-based `MCP::Resource`. The tools page documents it next to the other content types. https://modelcontextprotocol.io/specification/2026-07-28/server/tools#resource-links ## How Has This Been Tested? Added tests to test/mcp/content_test.rb covering the shape in the specification, the optional fields the link carries from the resource (`title`, `icons`, `annotations`, `size`, and `_meta`), and a class-based resource. At fb2e425 the three tests fail with `NameError`. ## Breaking Changes None. `Content::ResourceLink` is a new class.
yuki3738
force-pushed
the
add_content_resource_link
branch
from
November 22, 2026 16:28
577f3f8 to
5870fec
Compare
yuki3738
marked this pull request as ready for review
November 23, 2026 04:12
Owner
Author
|
Submitted upstream as modelcontextprotocol#710 and merged in b20fe62. |
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 spec defines a resource link content type (since 2025-06-18) that lets a tool return a link to
a resource instead of its contents, but the SDK had no corresponding class.
MCP::Contentcovered the otherfour members of the specification's
ContentBlock(text, image, audio, and embedded resource) and hadno helper for building a resource link.
Add
Content::ResourceLink, which wraps a resource object and serializes it viato_h, asContent::EmbeddedResource(modelcontextprotocol#244) does for resource contents. In the specification,ResourceLinkextendsResourcewithtype: "resource_link", so the link is the resource's ownto_hwith thattypeadded andcarries the resource's
title,icons,annotations,size, and_meta. It accepts a resource built withMCP::Resource.newand a class-basedMCP::Resource. The tools page documents it next to the other contenttypes.
https://modelcontextprotocol.io/specification/2026-07-28/server/tools#resource-links
How Has This Been Tested?
Added tests to test/mcp/content_test.rb covering the shape in the specification, the optional fields the link
carries from the resource (
title,icons,annotations,size, and_meta), and a class-based resource.At fb2e425 the three tests fail with
NameError.Breaking Changes
None.
Content::ResourceLinkis a new class.Types of changes
Checklist