class RubyLLM::MCP::Configuration
def initialize
def initialize @sampling = Sampling.new set_defaults end
def inspect
def inspect redacted = lambda do |name, value| if name.match?(/_id|_key|_secret|_token$/) value.nil? ? "nil" : "[FILTERED]" else value end end inspection = instance_variables.map do |ivar| name = ivar.to_s.delete_prefix("@") value = redacted[name, instance_variable_get(ivar)] "#{name}: #{value}" end.join(", ") "#<#{self.class}:0x#{object_id.to_s(16)} #{inspection}>" end
def load_mcps_config
def load_mcps_config @config_file ||= ConfigFile.new(config_path) @config_file.parse end
def logger
def logger @logger ||= Logger.new( log_file, progname: "RubyLLM::MCP", level: log_level ) end
def mcp_configuration
def mcp_configuration @mcp_configuration + load_mcps_config end
def on_elicitation(&block)
def on_elicitation(&block) @on_elicitation = block if block_given? @on_elicitation end
def on_human_in_the_loop(&block)
def on_human_in_the_loop(&block) @on_human_in_the_loop = block if block_given? @on_human_in_the_loop end
def on_logging(&block)
def on_logging(&block) @on_logging = block if block_given? @on_logging end
def on_progress(&block)
def on_progress(&block) @on_progress = block if block_given? @on_progress end
def reset!
def reset! set_defaults end
def set_defaults
def set_defaults # Connection configuration @request_timeout = REQUEST_TIMEOUT_DEFAULT # Connection Pool @max_connections = Float::INFINITY @pool_timeout = 5 # Logging configuration @log_file = $stdout @log_level = ENV["RUBYLLM_MCP_DEBUG"] ? Logger::DEBUG : Logger::INFO @logger = nil # Complex parameters support @has_support_complex_parameters = false # MCPs configuration @mcps_config_path = nil @mcp_configuration = [] # Rails specific configuration @launch_control = :automatic # Roots configuration @roots = [] # Sampling configuration @sampling.reset! # Event handlers @on_progress = nil @on_human_in_the_loop = nil @on_elicitation = nil @on_logging_level = nil @on_logging = nil end
def support_complex_parameters!
def support_complex_parameters! warn "[DEPRECATION] config.support_complex_parameters! is no longer needed and will be removed in version 0.8.0" return if @has_support_complex_parameters @has_support_complex_parameters = true RubyLLM::MCP.support_complex_parameters! end