Class: MCPClient::Resource
- Inherits:
-
Object
- Object
- MCPClient::Resource
- Defined in:
- lib/mcp_client/resource.rb
Overview
Representation of an MCP resource
Instance Attribute Summary collapse
-
#annotations ⇒ Hash?
readonly
Optional annotations that provide hints to clients.
-
#description ⇒ String?
readonly
Optional description.
-
#icons ⇒ Array<Hash>?
readonly
Optional icons for display in user interfaces (MCP 2025-11-25, SEP-973).
-
#meta ⇒ Hash?
readonly
Optional
_metametadata attached to the resource (MCP 2025-11-25). -
#mime_type ⇒ String?
readonly
Optional MIME type.
-
#name ⇒ String
readonly
The name of the resource.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#size ⇒ Integer?
readonly
Optional size in bytes.
-
#title ⇒ String?
readonly
Optional human-readable name of the resource for display purposes.
-
#uri ⇒ String
readonly
Unique identifier for the resource.
Class Method Summary collapse
-
.from_json(data, server: nil) ⇒ MCPClient::Resource
Create a Resource instance from JSON data.
Instance Method Summary collapse
-
#initialize(uri:, name:, title: nil, description: nil, mime_type: nil, size: nil, annotations: nil, icons: nil, meta: nil, server: nil) ⇒ Resource
constructor
Initialize a new resource rubocop:disable Metrics/ParameterLists.
-
#last_modified ⇒ String?
Return the lastModified annotation value (ISO 8601 timestamp string).
Constructor Details
#initialize(uri:, name:, title: nil, description: nil, mime_type: nil, size: nil, annotations: nil, icons: nil, meta: nil, server: nil) ⇒ Resource
Initialize a new resource rubocop:disable Metrics/ParameterLists
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mcp_client/resource.rb', line 40 def initialize(uri:, name:, title: nil, description: nil, mime_type: nil, size: nil, annotations: nil, icons: nil, meta: nil, server: nil) @uri = uri @name = name @title = title @description = description @mime_type = mime_type @size = size @annotations = annotations @icons = icons @meta = @server = server end |
Instance Attribute Details
#annotations ⇒ Hash? (readonly)
Returns optional annotations that provide hints to clients.
26 |
# File 'lib/mcp_client/resource.rb', line 26 attr_reader :uri, :name, :title, :description, :mime_type, :size, :annotations, :icons, :meta, :server |
#description ⇒ String? (readonly)
Returns optional description.
26 |
# File 'lib/mcp_client/resource.rb', line 26 attr_reader :uri, :name, :title, :description, :mime_type, :size, :annotations, :icons, :meta, :server |
#icons ⇒ Array<Hash>? (readonly)
Returns optional icons for display in user interfaces (MCP 2025-11-25, SEP-973).
26 |
# File 'lib/mcp_client/resource.rb', line 26 attr_reader :uri, :name, :title, :description, :mime_type, :size, :annotations, :icons, :meta, :server |
#meta ⇒ Hash? (readonly)
Returns optional _meta metadata attached to the resource (MCP 2025-11-25).
26 |
# File 'lib/mcp_client/resource.rb', line 26 attr_reader :uri, :name, :title, :description, :mime_type, :size, :annotations, :icons, :meta, :server |
#mime_type ⇒ String? (readonly)
Returns optional MIME type.
26 |
# File 'lib/mcp_client/resource.rb', line 26 attr_reader :uri, :name, :title, :description, :mime_type, :size, :annotations, :icons, :meta, :server |
#name ⇒ String (readonly)
Returns the name of the resource.
26 |
# File 'lib/mcp_client/resource.rb', line 26 attr_reader :uri, :name, :title, :description, :mime_type, :size, :annotations, :icons, :meta, :server |
#server ⇒ Object (readonly)
Returns the value of attribute server.
26 |
# File 'lib/mcp_client/resource.rb', line 26 attr_reader :uri, :name, :title, :description, :mime_type, :size, :annotations, :icons, :meta, :server |
#size ⇒ Integer? (readonly)
Returns optional size in bytes.
26 |
# File 'lib/mcp_client/resource.rb', line 26 attr_reader :uri, :name, :title, :description, :mime_type, :size, :annotations, :icons, :meta, :server |
#title ⇒ String? (readonly)
Returns optional human-readable name of the resource for display purposes.
26 |
# File 'lib/mcp_client/resource.rb', line 26 attr_reader :uri, :name, :title, :description, :mime_type, :size, :annotations, :icons, :meta, :server |
#uri ⇒ String (readonly)
Returns unique identifier for the resource.
26 27 28 |
# File 'lib/mcp_client/resource.rb', line 26 def uri @uri end |
Class Method Details
.from_json(data, server: nil) ⇒ MCPClient::Resource
Create a Resource instance from JSON data
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/mcp_client/resource.rb', line 67 def self.from_json(data, server: nil) new( uri: data['uri'], name: data['name'], title: data['title'], description: data['description'], mime_type: data['mimeType'], size: data['size'], annotations: data['annotations'], icons: data['icons'], meta: data['_meta'], server: server ) end |
Instance Method Details
#last_modified ⇒ String?
Return the lastModified annotation value (ISO 8601 timestamp string)
57 58 59 60 61 |
# File 'lib/mcp_client/resource.rb', line 57 def last_modified return nil unless @annotations.is_a?(Hash) @annotations['lastModified'] || @annotations[:lastModified] end |