Class: ActionMCP::Content::ResourceLink
- Defined in:
- lib/action_mcp/content/resource_link.rb
Overview
ResourceLink represents a link to a resource that the server is capable of reading. It's included in a prompt or tool call result. Note: resource links returned by tools are not guaranteed to appear in resources/list requests.
Instance Attribute Summary collapse
- #description ⇒ String? readonly
- #mime_type ⇒ String? readonly
- #name ⇒ String? readonly
- #uri ⇒ String? readonly
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(uri, name:, description: nil, mime_type: nil, annotations: nil) ⇒ ResourceLink
constructor
Initializes a new ResourceLink content.
-
#to_h ⇒ Hash
Returns a hash representation of the resource link content.
Methods inherited from Base
Constructor Details
#initialize(uri, name:, description: nil, mime_type: nil, annotations: nil) ⇒ ResourceLink
Initializes a new ResourceLink content.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/action_mcp/content/resource_link.rb', line 22 def initialize(uri, name:, description: nil, mime_type: nil, annotations: nil) raise ArgumentError, "uri must be a non-empty string" unless uri.is_a?(String) && uri.present? raise ArgumentError, "name must be a non-empty string" unless name.is_a?(String) && name.present? unless description.nil? || description.is_a?(String) raise ArgumentError, "description must be a string or nil" end unless mime_type.nil? || mime_type.is_a?(String) raise ArgumentError, "mime_type must be a string or nil" end super("resource_link", annotations: annotations) @uri = uri @name = name @description = description @mime_type = mime_type to_h end |
Instance Attribute Details
#description ⇒ String? (readonly)
13 14 15 |
# File 'lib/action_mcp/content/resource_link.rb', line 13 def description @description end |
#mime_type ⇒ String? (readonly)
13 14 15 |
# File 'lib/action_mcp/content/resource_link.rb', line 13 def mime_type @mime_type end |
#name ⇒ String? (readonly)
13 14 15 |
# File 'lib/action_mcp/content/resource_link.rb', line 13 def name @name end |
#uri ⇒ String? (readonly)
13 14 15 |
# File 'lib/action_mcp/content/resource_link.rb', line 13 def uri @uri end |
Instance Method Details
#to_h ⇒ Hash
Returns a hash representation of the resource link content.
43 44 45 46 47 48 49 |
# File 'lib/action_mcp/content/resource_link.rb', line 43 def to_h result = super.merge(uri: @uri, name: @name) result[:description] = @description if @description result[:mimeType] = @mime_type if @mime_type Validation.validate_content_block!(result) result end |