Class: Legion::Tools::Config

Inherits:
Base
  • Object
show all
Extended by:
Logging::Helper
Defined in:
lib/legion/tools/config.rb

Constant Summary collapse

SENSITIVE_KEYS =
%i[password secret token key cert private_key api_key].freeze

Class Method Summary collapse

Methods inherited from Base

deferred, deferred?, description, error_response, extension, handle_exception, input_schema, log, mcp_category, mcp_tier, runner, tags, text_response, tool_name, trigger_words

Class Method Details

.call(section: nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/legion/tools/config.rb', line 20

def call(section: nil)
  settings = Legion::Settings.loader.to_hash

  if section
    key = section.to_sym
    return error_response("Setting '#{section}' not found") unless settings.key?(key)

    value = settings[key]
    value = redact_hash(value) if value.is_a?(Hash)
    text_response({ key: key, value: value })
  else
    text_response(redact_hash(settings))
  end
rescue StandardError => e
  handle_exception(e, level: :warn, handled: true, operation: :tool_config_call)
  error_response("Failed to get config: #{e.message}")
end