Class: KairosMcp::ToolContext
- Inherits:
-
Object
- Object
- KairosMcp::ToolContext
- Defined in:
- lib/kairos_mcp/skill_contexts.rb
Overview
Tool block context - defines MCP tool interface and implementation
Instance Attribute Summary collapse
-
#executor ⇒ Object
readonly
Returns the value of attribute executor.
-
#tool_description ⇒ Object
readonly
Returns the value of attribute tool_description.
-
#tool_name ⇒ Object
readonly
Returns the value of attribute tool_name.
Instance Method Summary collapse
- #description(value) ⇒ Object
-
#execute(&block) ⇒ Object
Execute block for tool implementation (with args).
-
#initialize ⇒ ToolContext
constructor
A new instance of ToolContext.
- #input(&block) ⇒ Object
- #input_schema ⇒ Object
- #name(value) ⇒ Object
- #property(name, type:, description:) ⇒ Object
- #required(*names) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ ToolContext
Returns a new instance of ToolContext.
57 58 59 60 61 |
# File 'lib/kairos_mcp/skill_contexts.rb', line 57 def initialize @input_properties = {} @required_inputs = [] @executor = nil end |
Instance Attribute Details
#executor ⇒ Object (readonly)
Returns the value of attribute executor.
55 56 57 |
# File 'lib/kairos_mcp/skill_contexts.rb', line 55 def executor @executor end |
#tool_description ⇒ Object (readonly)
Returns the value of attribute tool_description.
55 56 57 |
# File 'lib/kairos_mcp/skill_contexts.rb', line 55 def tool_description @tool_description end |
#tool_name ⇒ Object (readonly)
Returns the value of attribute tool_name.
55 56 57 |
# File 'lib/kairos_mcp/skill_contexts.rb', line 55 def tool_name @tool_name end |
Instance Method Details
#description(value) ⇒ Object
67 68 69 |
# File 'lib/kairos_mcp/skill_contexts.rb', line 67 def description(value) @tool_description = value end |
#execute(&block) ⇒ Object
Execute block for tool implementation (with args)
84 85 86 |
# File 'lib/kairos_mcp/skill_contexts.rb', line 84 def execute(&block) @executor = block end |
#input(&block) ⇒ Object
71 72 73 |
# File 'lib/kairos_mcp/skill_contexts.rb', line 71 def input(&block) instance_eval(&block) if block_given? end |
#input_schema ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/kairos_mcp/skill_contexts.rb', line 88 def input_schema { type: 'object', properties: @input_properties.transform_keys(&:to_s).transform_values { |v| { type: v[:type], description: v[:description] } }, required: @required_inputs.map(&:to_s) } end |
#name(value) ⇒ Object
63 64 65 |
# File 'lib/kairos_mcp/skill_contexts.rb', line 63 def name(value) @tool_name = value end |
#property(name, type:, description:) ⇒ Object
75 76 77 |
# File 'lib/kairos_mcp/skill_contexts.rb', line 75 def property(name, type:, description:) @input_properties[name.to_sym] = { type: type, description: description } end |
#required(*names) ⇒ Object
79 80 81 |
# File 'lib/kairos_mcp/skill_contexts.rb', line 79 def required(*names) @required_inputs.concat(names.map(&:to_sym)) end |
#to_h ⇒ Object
98 99 100 101 102 103 104 105 |
# File 'lib/kairos_mcp/skill_contexts.rb', line 98 def to_h { name: @tool_name, description: @tool_description, input_schema: input_schema, has_executor: !@executor.nil? } end |