Class: ModelContextProtocol::Server::Resource
- Inherits:
-
Object
- Object
- ModelContextProtocol::Server::Resource
- Includes:
- Cancellable, Progressable
- Defined in:
- lib/model_context_protocol/server/resource.rb
Defined Under Namespace
Classes: AnnotationsDSL, DefinitionDSL
Class Attribute Summary collapse
-
.annotations ⇒ Object
readonly
Returns the value of attribute annotations.
-
.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.
-
.title ⇒ Object
readonly
Returns the value of attribute title.
-
.uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Attribute Summary collapse
-
#client_logger ⇒ Object
readonly
Returns the value of attribute client_logger.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#mime_type ⇒ Object
readonly
Returns the value of attribute mime_type.
-
#server_logger ⇒ Object
readonly
Returns the value of attribute server_logger.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Class Method Summary collapse
- .call(client_logger, server_logger, context = {}) ⇒ Object
- .define(&block) ⇒ Object
- .definition ⇒ Object
- .inherited(subclass) ⇒ Object
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(client_logger, server_logger, context = {}) ⇒ Resource
constructor
A new instance of Resource.
Methods included from Progressable
Methods included from Cancellable
Constructor Details
#initialize(client_logger, server_logger, context = {}) ⇒ Resource
Returns a new instance of Resource.
8 9 10 11 12 13 14 |
# File 'lib/model_context_protocol/server/resource.rb', line 8 def initialize(client_logger, server_logger, context = {}) @mime_type = self.class.mime_type @uri = self.class.uri @client_logger = client_logger @server_logger = server_logger @context = context end |
Class Attribute Details
.annotations ⇒ Object (readonly)
Returns the value of attribute annotations.
54 55 56 |
# File 'lib/model_context_protocol/server/resource.rb', line 54 def annotations @annotations end |
.description ⇒ Object (readonly)
Returns the value of attribute description.
54 55 56 |
# File 'lib/model_context_protocol/server/resource.rb', line 54 def description @description end |
.mime_type ⇒ Object (readonly)
Returns the value of attribute mime_type.
54 55 56 |
# File 'lib/model_context_protocol/server/resource.rb', line 54 def mime_type @mime_type end |
.name ⇒ Object (readonly)
Returns the value of attribute name.
54 55 56 |
# File 'lib/model_context_protocol/server/resource.rb', line 54 def name @name end |
.title ⇒ Object (readonly)
Returns the value of attribute title.
54 55 56 |
# File 'lib/model_context_protocol/server/resource.rb', line 54 def title @title end |
.uri ⇒ Object (readonly)
Returns the value of attribute uri.
54 55 56 |
# File 'lib/model_context_protocol/server/resource.rb', line 54 def uri @uri end |
Instance Attribute Details
#client_logger ⇒ Object (readonly)
Returns the value of attribute client_logger.
6 7 8 |
# File 'lib/model_context_protocol/server/resource.rb', line 6 def client_logger @client_logger end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
6 7 8 |
# File 'lib/model_context_protocol/server/resource.rb', line 6 def context @context end |
#mime_type ⇒ Object (readonly)
Returns the value of attribute mime_type.
6 7 8 |
# File 'lib/model_context_protocol/server/resource.rb', line 6 def mime_type @mime_type end |
#server_logger ⇒ Object (readonly)
Returns the value of attribute server_logger.
6 7 8 |
# File 'lib/model_context_protocol/server/resource.rb', line 6 def server_logger @server_logger end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/model_context_protocol/server/resource.rb', line 6 def uri @uri end |
Class Method Details
.call(client_logger, server_logger, context = {}) ⇒ Object
77 78 79 |
# File 'lib/model_context_protocol/server/resource.rb', line 77 def call(client_logger, server_logger, context = {}) new(client_logger, server_logger, context).call end |
.define(&block) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/model_context_protocol/server/resource.rb', line 56 def define(&block) definition_dsl = DefinitionDSL.new definition_dsl.instance_eval(&block) @name = definition_dsl.name @description = definition_dsl.description @title = definition_dsl.title @mime_type = definition_dsl.mime_type @uri = definition_dsl.uri @annotations = definition_dsl.defined_annotations end |
.definition ⇒ Object
81 82 83 84 85 86 |
# File 'lib/model_context_protocol/server/resource.rb', line 81 def definition result = {name: @name, description: @description, mimeType: @mime_type, uri: @uri} result[:title] = @title if @title result[:annotations] = @annotations.serialized if @annotations result end |
.inherited(subclass) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/model_context_protocol/server/resource.rb', line 68 def inherited(subclass) subclass.instance_variable_set(:@name, @name) subclass.instance_variable_set(:@description, @description) subclass.instance_variable_set(:@title, @title) subclass.instance_variable_set(:@mime_type, @mime_type) subclass.instance_variable_set(:@uri, @uri) subclass.instance_variable_set(:@annotations, @annotations&.dup) end |
Instance Method Details
#call ⇒ Object
16 17 18 |
# File 'lib/model_context_protocol/server/resource.rb', line 16 def call raise NotImplementedError, "Subclasses must implement the call method" end |