Class: ActionMCP::Resource
- Inherits:
-
Data
- Object
- Data
- ActionMCP::Resource
- Defined in:
- lib/action_mcp/resource.rb
Overview
Represents a resource with its metadata.
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#mime_type ⇒ Object
readonly
Returns the value of attribute mime_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#to_h ⇒ Hash
Convert the resource to a hash with the keys expected by MCP.
- #to_json ⇒ Object
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description
5 6 7 |
# File 'lib/action_mcp/resource.rb', line 5 def description @description end |
#mime_type ⇒ Object (readonly)
Returns the value of attribute mime_type
5 6 7 |
# File 'lib/action_mcp/resource.rb', line 5 def mime_type @mime_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name
5 6 7 |
# File 'lib/action_mcp/resource.rb', line 5 def name @name end |
#size ⇒ Object (readonly)
Returns the value of attribute size
5 6 7 |
# File 'lib/action_mcp/resource.rb', line 5 def size @size end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri
5 6 7 |
# File 'lib/action_mcp/resource.rb', line 5 def uri @uri end |
Instance Method Details
#to_h ⇒ Hash
Convert the resource to a hash with the keys expected by MCP. Note: The key for mime_type is converted to ‘mimeType’ as specified.
10 11 12 13 14 15 16 |
# File 'lib/action_mcp/resource.rb', line 10 def to_h hash = { uri: uri, name: name } hash[:description] = description if description hash[:mimeType] = mime_type if mime_type hash[:size] = size if size hash end |
#to_json ⇒ Object
18 19 20 |
# File 'lib/action_mcp/resource.rb', line 18 def to_json(*) MultiJson.dump(to_h, *) end |