Class: RubyLLM::MCP::Configuration
- Inherits:
-
Object
- Object
- RubyLLM::MCP::Configuration
- Defined in:
- lib/ruby_llm/mcp/configuration.rb
Defined Under Namespace
Classes: AdapterConfig, ConfigFile, Elicitation, OAuth, Sampling, Tasks
Constant Summary collapse
- REQUEST_TIMEOUT_DEFAULT =
8000- VALID_PROTOCOL_TRACKS =
%i[stable draft].freeze
Instance Attribute Summary collapse
-
#adapter_config ⇒ Object
Returns the value of attribute adapter_config.
-
#config_path ⇒ Object
Returns the value of attribute config_path.
-
#elicitation ⇒ Object
Returns the value of attribute elicitation.
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
-
#launch_control ⇒ Object
Returns the value of attribute launch_control.
-
#log_file ⇒ Object
Returns the value of attribute log_file.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
- #logger ⇒ Object
-
#max_connections ⇒ Object
Returns the value of attribute max_connections.
-
#mcp_configuration ⇒ Object
Validate MCP configuration before use.
-
#oauth ⇒ Object
Returns the value of attribute oauth.
-
#on_logging_level ⇒ Object
Returns the value of attribute on_logging_level.
-
#pool_timeout ⇒ Object
Returns the value of attribute pool_timeout.
-
#protocol_track ⇒ Object
Returns the value of attribute protocol_track.
-
#protocol_version ⇒ Object
Returns the effective protocol version: explicit protocol_version > protocol_track-derived default.
-
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
-
#roots ⇒ Object
Returns the value of attribute roots.
-
#sampling ⇒ Object
Returns the value of attribute sampling.
-
#tasks ⇒ Object
Returns the value of attribute tasks.
Instance Method Summary collapse
- #default_adapter ⇒ Object
-
#default_adapter=(adapter) ⇒ Object
Convenience method for setting default adapter.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #inspect ⇒ Object
- #on_elicitation(&block) ⇒ Object
- #on_human_in_the_loop(handler_class = nil, **options) ⇒ Object
- #on_logging(&block) ⇒ Object
- #on_progress(&block) ⇒ Object
- #reset! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
221 222 223 224 225 226 227 228 229 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 221 def initialize @sampling = Sampling.new @elicitation = Elicitation.new @tasks = Tasks.new @adapter_config = AdapterConfig.new @extensions = Extensions::Configuration.new @oauth = OAuth.new set_defaults end |
Instance Attribute Details
#adapter_config ⇒ Object
Returns the value of attribute adapter_config.
200 201 202 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 200 def adapter_config @adapter_config end |
#config_path ⇒ Object
Returns the value of attribute config_path.
200 201 202 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 200 def config_path @config_path end |
#elicitation ⇒ Object
Returns the value of attribute elicitation.
200 201 202 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 200 def elicitation @elicitation end |
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
215 216 217 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 215 def extensions @extensions end |
#launch_control ⇒ Object
Returns the value of attribute launch_control.
200 201 202 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 200 def launch_control @launch_control end |
#log_file ⇒ Object
Returns the value of attribute log_file.
200 201 202 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 200 def log_file @log_file end |
#log_level ⇒ Object
Returns the value of attribute log_level.
200 201 202 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 200 def log_level @log_level end |
#logger ⇒ Object
235 236 237 238 239 240 241 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 235 def logger @logger ||= Logger.new( log_file, progname: "RubyLLM::MCP", level: log_level ) end |
#max_connections ⇒ Object
Returns the value of attribute max_connections.
200 201 202 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 200 def max_connections @max_connections end |
#mcp_configuration ⇒ Object
Validate MCP configuration before use
253 254 255 256 257 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 253 def mcp_configuration configs = @mcp_configuration + load_mcps_config validate_configurations!(configs) configs end |
#oauth ⇒ Object
Returns the value of attribute oauth.
200 201 202 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 200 def oauth @oauth end |
#on_logging_level ⇒ Object
Returns the value of attribute on_logging_level.
200 201 202 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 200 def on_logging_level @on_logging_level end |
#pool_timeout ⇒ Object
Returns the value of attribute pool_timeout.
200 201 202 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 200 def pool_timeout @pool_timeout end |
#protocol_track ⇒ Object
Returns the value of attribute protocol_track.
215 216 217 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 215 def protocol_track @protocol_track end |
#protocol_version ⇒ Object
Returns the effective protocol version: explicit protocol_version > protocol_track-derived default.
297 298 299 300 301 302 303 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 297 def protocol_version return @protocol_version unless @protocol_version.nil? return Native::Protocol.draft_version if @protocol_track == :draft Native::Protocol.latest_version end |
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
200 201 202 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 200 def request_timeout @request_timeout end |
#roots ⇒ Object
Returns the value of attribute roots.
200 201 202 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 200 def roots @roots end |
#sampling ⇒ Object
Returns the value of attribute sampling.
200 201 202 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 200 def sampling @sampling end |
#tasks ⇒ Object
Returns the value of attribute tasks.
200 201 202 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 200 def tasks @tasks end |
Instance Method Details
#default_adapter ⇒ Object
248 249 250 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 248 def default_adapter @adapter_config.default_adapter end |
#default_adapter=(adapter) ⇒ Object
Convenience method for setting default adapter
244 245 246 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 244 def default_adapter=(adapter) @adapter_config.default_adapter = adapter end |
#inspect ⇒ Object
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 305 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 |
#on_elicitation(&block) ⇒ Object
280 281 282 283 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 280 def on_elicitation(&block) @on_elicitation = block if block_given? @on_elicitation end |
#on_human_in_the_loop(handler_class = nil, **options) ⇒ Object
264 265 266 267 268 269 270 271 272 273 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 264 def on_human_in_the_loop(handler_class = nil, **) if block_given? raise ArgumentError, "Block-based human-in-the-loop callbacks are no longer supported. Use a handler class." end if handler_class @on_human_in_the_loop = { class: handler_class, options: } end @on_human_in_the_loop end |
#on_logging(&block) ⇒ Object
275 276 277 278 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 275 def on_logging(&block) @on_logging = block if block_given? @on_logging end |
#on_progress(&block) ⇒ Object
259 260 261 262 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 259 def on_progress(&block) @on_progress = block if block_given? @on_progress end |
#reset! ⇒ Object
231 232 233 |
# File 'lib/ruby_llm/mcp/configuration.rb', line 231 def reset! set_defaults end |