Class: KairosMcp::Tools::BaseTool

Inherits:
Object
  • Object
show all
Defined in:
lib/kairos_mcp/tools/base_tool.rb

Instance Method Summary collapse

Constructor Details

#initialize(safety = nil, registry: nil) ⇒ BaseTool

Returns a new instance of BaseTool.



6
7
8
9
# File 'lib/kairos_mcp/tools/base_tool.rb', line 6

def initialize(safety = nil, registry: nil)
  @safety = safety
  @registry = registry
end

Instance Method Details

#call(arguments) ⇒ Object

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/kairos_mcp/tools/base_tool.rb', line 40

def call(arguments)
  raise NotImplementedError
end

#categorySymbol

Category for grouping tools in catalog

Returns:

  • (Symbol)

    one of :chain, :knowledge, :context, :skills, :resource, :state, :guide, :utility



49
50
51
# File 'lib/kairos_mcp/tools/base_tool.rb', line 49

def category
  :utility
end

#descriptionObject

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/kairos_mcp/tools/base_tool.rb', line 32

def description
  raise NotImplementedError
end

#examplesArray<Hash>

Usage examples for this tool

Returns:

  • (Array<Hash>)

    list of examples with :title and :code keys



61
62
63
# File 'lib/kairos_mcp/tools/base_tool.rb', line 61

def examples
  []
end

#input_schemaObject

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/kairos_mcp/tools/base_tool.rb', line 36

def input_schema
  raise NotImplementedError
end

#invoke_tool(tool_name, arguments = {}, context: nil) ⇒ Object

Invoke another tool through the same ToolRegistry, preserving the full gate pipeline and invocation policy (whitelist/blacklist/depth). Only available when the tool was registered with a registry reference.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/kairos_mcp/tools/base_tool.rb', line 14

def invoke_tool(tool_name, arguments = {}, context: nil)
  raise "Tool invocation not available (no registry)" unless @registry

  ctx = context || InvocationContext.new
  child_ctx = ctx.child(caller_tool: name)

  unless child_ctx.allowed?(tool_name)
    raise InvocationContext::PolicyDeniedError,
          "Tool '#{tool_name}' blocked by invocation policy (caller: #{name})"
  end

  @registry.call_tool(tool_name, arguments, invocation_context: child_ctx)
end

#nameObject

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/kairos_mcp/tools/base_tool.rb', line 28

def name
  raise NotImplementedError
end

Related tools that are often used together

Returns:

  • (Array<String>)

    list of tool names



67
68
69
# File 'lib/kairos_mcp/tools/base_tool.rb', line 67

def related_tools
  []
end

#to_full_schemaObject

Extended schema including metadata (for internal use)



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/kairos_mcp/tools/base_tool.rb', line 81

def to_full_schema
  {
    name: name,
    description: description,
    inputSchema: input_schema,
    _metadata: {
      category: category,
      usecase_tags: usecase_tags,
      examples: examples,
      related_tools: related_tools
    }
  }
end

#to_schemaObject

Schema for MCP protocol



72
73
74
75
76
77
78
# File 'lib/kairos_mcp/tools/base_tool.rb', line 72

def to_schema
  {
    name: name,
    description: description,
    inputSchema: input_schema
  }
end

#usecase_tagsArray<String>

Tags for keyword-based search and recommendations

Returns:

  • (Array<String>)

    list of usecase tags (e.g., [“save”, “update”, “L1”])



55
56
57
# File 'lib/kairos_mcp/tools/base_tool.rb', line 55

def usecase_tags
  []
end