-
Notifications
You must be signed in to change notification settings - Fork 635
feat: add ResourceLink type and parsing support #407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add ResourceLink type for tool result. - Add NewResourceLink function to create ResourceLink instances. - Add ResourceLink parsing support in ParseContent function.
WalkthroughA new content type, Changes
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (1.64.8)Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
mcp/utils.go (1)
71-98
: Add missing AsResourceLink helper function for consistency.All other content types have corresponding type assertion helpers, but ResourceLink is missing one. Add this function to maintain consistency:
// AsEmbeddedResource attempts to cast the given interface to EmbeddedResource func AsEmbeddedResource(content any) (*EmbeddedResource, bool) { return asType[EmbeddedResource](content) } +// AsResourceLink attempts to cast the given interface to ResourceLink +func AsResourceLink(content any) (*ResourceLink, bool) { + return asType[ResourceLink](content) +} + // AsTextResourceContents attempts to cast the given interface to TextResourceContents func AsTextResourceContents(content any) (*TextResourceContents, bool) { return asType[TextResourceContents](content) }
🧹 Nitpick comments (1)
mcp/utils.go (1)
225-234
: Consider reordering fields to match struct declaration.The constructor works correctly but the field assignment order doesn't match the struct declaration order. Consider this minor adjustment for consistency:
func NewResourceLink(uri, name, description, mimeType string) ResourceLink { return ResourceLink{ Type: "resource_link", URI: uri, Name: name, + Description: description, MIMEType: mimeType, - Description: description, } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
mcp/types.go
(1 hunks)mcp/utils.go
(2 hunks)
🔇 Additional comments (2)
mcp/types.go (1)
868-882
: LGTM! The ResourceLink implementation follows established patterns.The struct definition correctly embeds
Annotated
, includes all necessary fields with proper JSON tags and documentation, and implements theContent
interface consistently with other content types.mcp/utils.go (1)
490-498
: LGTM! The parsing logic is correctly implemented.The resource_link case follows the established pattern for content parsing. Field validation and error handling are appropriate.
- Remove the requirement for description and mimeType when creating a ResourceLink, now only uri and name are mandatory. - Update the comment for the mimeType field from "resource link" to "resource" for terminology consistency.
Could this be used to return external web links as resources as asked in #422? |
feat: add ResourceLink type and parsing support (mark3labs#407)
Description
This PR adds support for parsing ResourceLink types according to the latest specification.
This PR adds the
ResourceLink
type implementation to align with the latest specification. The changes align with the specification defined at Model Context Protocol - Tools.Type of Change
Checklist
MCP Spec Compliance
Additional Information
Summary by CodeRabbit