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, icons: nil, meta: nil) ⇒ ResourceLink

Initialize a resource link rubocop:disable Metrics/ParameterLists

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

  • icons (Array<Hash>, nil) (defaults to: nil)

    optional icons for display in user interfaces (MCP 2025-11-25)

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

    optional _meta metadata attached to the resource link (MCP 2025-11-25)



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/mcp_client/resource_link.rb', line 39

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

Instance Attribute Details

#annotationsHash? (readonly)

Returns optional annotations that provide hints to clients.

Returns:

  • (Hash, nil)

    optional annotations that provide hints to clients



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

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

#descriptionString? (readonly)

Returns optional human-readable description.

Returns:

  • (String, nil)

    optional human-readable description



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

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

#iconsArray<Hash>? (readonly)

Returns optional icons for display in user interfaces (MCP 2025-11-25, SEP-973).

Returns:

  • (Array<Hash>, nil)

    optional icons for display in user interfaces (MCP 2025-11-25, SEP-973)



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

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

#metaObject (readonly)

Returns the value of attribute meta.



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

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

#mime_typeString? (readonly)

Returns optional MIME type of the resource.

Returns:

  • (String, nil)

    optional MIME type of the resource



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

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

#nameString (readonly)

Returns the name of the linked resource.

Returns:

  • (String)

    the name of the linked resource



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

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

#sizeInteger? (readonly)

Returns optional size of the resource in bytes.

Returns:

  • (Integer, nil)

    optional size of the resource in bytes



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

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

#titleString? (readonly)

Returns optional display title for the resource.

Returns:

  • (String, nil)

    optional display title for the resource



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

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

#uriString (readonly)

Returns URI of the linked resource.

Returns:

  • (String)

    URI of the linked resource



26
27
28
# File 'lib/mcp_client/resource_link.rb', line 26

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:



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/mcp_client/resource_link.rb', line 56

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'],
    icons: data['icons'],
    meta: data['_meta']
  )
end

Instance Method Details

#typeString

The content type identifier for this content type

Returns:

  • (String)

    'resource_link'



72
73
74
# File 'lib/mcp_client/resource_link.rb', line 72

def type
  'resource_link'
end