Class: Hitch::MCP::Result
- Inherits:
-
Object
- Object
- Hitch::MCP::Result
- Defined in:
- app/models/hitch/mcp/result.rb
Overview
Closed host return value for MCP tool execution. Constructors copy host values so later mutation cannot change the result Hitch validates.
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(kind, value, text) ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize(kind, value, text) ⇒ Result
Returns a new instance of Result.
53 54 55 56 57 58 |
# File 'app/models/hitch/mcp/result.rb', line 53 def initialize(kind, value, text) @kind = kind @value = value @text = text freeze end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
51 52 53 |
# File 'app/models/hitch/mcp/result.rb', line 51 def kind @kind end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
51 52 53 |
# File 'app/models/hitch/mcp/result.rb', line 51 def text @text end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
51 52 53 |
# File 'app/models/hitch/mcp/result.rb', line 51 def value @value end |
Class Method Details
.error(public_message) ⇒ Object
29 30 31 |
# File 'app/models/hitch/mcp/result.rb', line 29 def error() new(:error, copy_string(), nil) end |
.structured(value, text: nil) ⇒ Object
22 23 24 25 26 27 |
# File 'app/models/hitch/mcp/result.rb', line 22 def structured(value, text: nil) copied_text = text.nil? ? nil : copy_string(text) new(:structured, copy_json(value), copied_text) rescue SystemStackError raise ArgumentError, "MCP Result nesting is too deep" end |
.text(value) ⇒ Object
18 19 20 |
# File 'app/models/hitch/mcp/result.rb', line 18 def text(value) new(:text, copy_string(value), nil) end |