Class: Legion::MCP::Tools::StructuralIndexTool

Inherits:
MCP::Tool
  • Object
show all
Extended by:
Logging::Helper
Defined in:
lib/legion/mcp/tools/structural_index.rb

Class Method Summary collapse

Class Method Details

.call(extension: nil, type: nil, refresh: nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/legion/mcp/tools/structural_index.rb', line 32

def call(extension: nil, type: nil, refresh: nil)
  log.info('Starting legion.mcp.tools.structural_index.call')
  index = if refresh
            StructuralIndex.save_cache(StructuralIndex.build)
          else
            StructuralIndex.load_or_build
          end

  result = StructuralIndex.filter(index, extension: extension, type: type)
  text_response(result)
rescue StandardError => e
  handle_exception(e, level: :warn, operation: 'legion.mcp.tools.structural_index.call')
  log.warn("StructuralIndexTool#call failed: #{e.message}")
  error_response("Failed: #{e.message}")
end