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.



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

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

Instance Method Details

#call(arguments) ⇒ Object

Raises:

  • (NotImplementedError)


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

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



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

def category
  :utility
end

#descriptionObject

Raises:

  • (NotImplementedError)


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

def description
  raise NotImplementedError
end

#examplesArray<Hash>

Usage examples for this tool

Returns:

  • (Array<Hash>)

    list of examples with :title and :code keys



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

def examples
  []
end

#harness_requirementSymbol, Hash

Phase 1.5 — Capability Boundary self-articulation. Override in subclasses to declare harness dependence. Default :core means MCP + filesystem only, no subprocess, no harness-specific tool. See docs/drafts/capability_boundary_design_v1.1.md for the 8 invariants and tier rules.

Returns:

  • (Symbol, Hash)

    :core | :harness_assisted | :harness_specific OR Hash with keys: tier, requires_externals, requires_harness_features, fallback_chain, degrades_to, target_harness, reason, note, acknowledgment



80
81
82
# File 'lib/kairos_mcp/tools/base_tool.rb', line 80

def harness_requirement
  :core
end

#input_schemaObject

Raises:

  • (NotImplementedError)


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

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.



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

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)


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

def name
  raise NotImplementedError
end

Related tools that are often used together

Returns:

  • (Array<String>)

    list of tool names



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

def related_tools
  []
end

#to_full_schemaObject

Extended schema including metadata (for internal use)



94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/kairos_mcp/tools/base_tool.rb', line 94

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



85
86
87
88
89
90
91
# File 'lib/kairos_mcp/tools/base_tool.rb', line 85

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”])



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

def usecase_tags
  []
end