Class: MCP::Tool::Response
- Inherits:
-
Object
- Object
- MCP::Tool::Response
- Defined in:
- lib/mcp/tool/response.rb
Constant Summary collapse
- NOT_GIVEN =
Object.new.freeze
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(content, deprecated_error = NOT_GIVEN, error: false) ⇒ Response
constructor
A new instance of Response.
- #to_h ⇒ Object
Constructor Details
#initialize(content, deprecated_error = NOT_GIVEN, error: false) ⇒ Response
Returns a new instance of Response.
10 11 12 13 14 15 16 17 18 |
# File 'lib/mcp/tool/response.rb', line 10 def initialize(content, deprecated_error = NOT_GIVEN, error: false) if deprecated_error != NOT_GIVEN warn("Passing `error` with the 2nd argument of `Response.new` is deprecated. Use keyword argument like `Response.new(content, error: error)` instead.", uplevel: 1) error = deprecated_error end @content = content @error = error end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
8 9 10 |
# File 'lib/mcp/tool/response.rb', line 8 def content @content end |
Instance Method Details
#error? ⇒ Boolean
20 21 22 |
# File 'lib/mcp/tool/response.rb', line 20 def error? !!@error end |
#to_h ⇒ Object
24 25 26 |
# File 'lib/mcp/tool/response.rb', line 24 def to_h { content:, isError: error? }.compact end |