Class: MCPClient::ResourceLink

Inherits:
Object
  • Object
show all
Defined in:
lib/mcp_client/resource_link.rb

Overview

Representation of an MCP resource link in tool result content A resource link references a server resource that can be read separately. Used in tool results to point clients to available resources (MCP 2025-11-25).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri:, name:, description: nil, mime_type: nil, annotations: nil, title: nil, size: nil) ⇒ ResourceLink

Initialize a resource link

Parameters:

  • uri (String)

    URI of the linked resource

  • name (String)

    the name of the linked resource

  • description (String, nil) (defaults to: nil)

    optional human-readable description

  • mime_type (String, nil) (defaults to: nil)

    optional MIME type of the resource

  • annotations (Hash, nil) (defaults to: nil)

    optional annotations that provide hints to clients

  • title (String, nil) (defaults to: nil)

    optional display title for the resource

  • size (Integer, nil) (defaults to: nil)

    optional size of the resource in bytes



32
33
34
35
36
37
38
39
40
# File 'lib/mcp_client/resource_link.rb', line 32

def initialize(uri:, name:, description: nil, mime_type: nil, annotations: nil, title: nil, size: nil)
  @uri = uri
  @name = name
  @description = description
  @mime_type = mime_type
  @annotations = annotations
  @title = title
  @size = size
end

Instance Attribute Details

#annotationsHash? (readonly)

Returns optional annotations that provide hints to clients.

Returns:

  • (Hash, nil)

    optional annotations that provide hints to clients



22
# File 'lib/mcp_client/resource_link.rb', line 22

attr_reader :uri, :name, :description, :mime_type, :annotations, :title, :size

#descriptionString? (readonly)

Returns optional human-readable description.

Returns:

  • (String, nil)

    optional human-readable description



22
# File 'lib/mcp_client/resource_link.rb', line 22

attr_reader :uri, :name, :description, :mime_type, :annotations, :title, :size

#mime_typeString? (readonly)

Returns optional MIME type of the resource.

Returns:

  • (String, nil)

    optional MIME type of the resource



22
# File 'lib/mcp_client/resource_link.rb', line 22

attr_reader :uri, :name, :description, :mime_type, :annotations, :title, :size

#nameString (readonly)

Returns the name of the linked resource.

Returns:

  • (String)

    the name of the linked resource



22
# File 'lib/mcp_client/resource_link.rb', line 22

attr_reader :uri, :name, :description, :mime_type, :annotations, :title, :size

#sizeObject (readonly)

Returns the value of attribute size.



22
# File 'lib/mcp_client/resource_link.rb', line 22

attr_reader :uri, :name, :description, :mime_type, :annotations, :title, :size

#titleString? (readonly)

Returns optional display title for the resource.

Returns:

  • (String, nil)

    optional display title for the resource



22
# File 'lib/mcp_client/resource_link.rb', line 22

attr_reader :uri, :name, :description, :mime_type, :annotations, :title, :size

#uriString (readonly)

Returns URI of the linked resource.

Returns:

  • (String)

    URI of the linked resource



22
23
24
# File 'lib/mcp_client/resource_link.rb', line 22

def uri
  @uri
end

Class Method Details

.from_json(data) ⇒ MCPClient::ResourceLink

Create a ResourceLink instance from JSON data

Parameters:

  • data (Hash)

    JSON data from MCP server (content item with type ‘resource_link’)

Returns:



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/mcp_client/resource_link.rb', line 45

def self.from_json(data)
  new(
    uri: data['uri'],
    name: data['name'],
    description: data['description'],
    mime_type: data['mimeType'],
    annotations: data['annotations'],
    title: data['title'],
    size: data['size']
  )
end

Instance Method Details

#typeString

The content type identifier for this content type

Returns:

  • (String)

    ‘resource_link’



59
60
61
# File 'lib/mcp_client/resource_link.rb', line 59

def type
  'resource_link'
end