Class: Legion::MCP::Tools::DiscoverTools

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

Class Method Summary collapse

Class Method Details

.call(category: nil, intent: nil, tool_names: nil, schema: nil) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/legion/mcp/tools/discover_tools.rb', line 36

def call(category: nil, intent: nil, tool_names: nil, schema: nil)
  log.info('Starting legion.mcp.tools.discover_tools.call')
  if tool_names && schema
    resolve_schemas(tool_names)
  elsif category
    lookup_category(category)
  elsif intent
    results = ContextCompiler.match_tools(intent, limit: 5)
    text_response({ matched_tools: results })
  else
    text_response(ContextCompiler.compressed_catalog)
  end
rescue StandardError => e
  handle_exception(e, level: :warn, operation: 'legion.mcp.tools.discover_tools.call')
  log.warn("DiscoverTools#call failed: #{e.message}")
  error_response("Failed: #{e.message}")
end