Class: RailsActiveMcp::Configuration
- Inherits:
-
Object
- Object
- RailsActiveMcp::Configuration
- Defined in:
- lib/rails_active_mcp/configuration.rb
Instance Attribute Summary collapse
-
#allowed_models ⇒ Object
Returns the value of attribute allowed_models.
-
#audit_file ⇒ Object
Safety and execution options.
-
#command_timeout ⇒ Object
Core configuration options.
-
#custom_safety_patterns ⇒ Object
Returns the value of attribute custom_safety_patterns.
-
#enable_logging ⇒ Object
Core configuration options.
-
#enabled ⇒ Object
Safety and execution options.
-
#log_executions ⇒ Object
Safety and execution options.
-
#log_level ⇒ Object
Core configuration options.
-
#max_results ⇒ Object
Safety and execution options.
-
#safe_mode ⇒ Object
Safety and execution options.
Instance Method Summary collapse
- #development_mode! ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #model_allowed?(model_name) ⇒ Boolean
-
#production_mode! ⇒ Object
Environment-specific configuration presets.
- #reset! ⇒ Object
- #test_mode! ⇒ Object
- #valid? ⇒ Boolean
- #validate? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rails_active_mcp/configuration.rb', line 14 def initialize @command_timeout = 30 @enable_logging = true @log_level = :info # Safety and execution defaults @safe_mode = true @max_results = 100 @log_executions = false @audit_file = nil @custom_safety_patterns = [] @allowed_models = [] @enabled = true end |
Instance Attribute Details
#allowed_models ⇒ Object
Returns the value of attribute allowed_models.
12 13 14 |
# File 'lib/rails_active_mcp/configuration.rb', line 12 def allowed_models @allowed_models end |
#audit_file ⇒ Object
Safety and execution options
11 12 13 |
# File 'lib/rails_active_mcp/configuration.rb', line 11 def audit_file @audit_file end |
#command_timeout ⇒ Object
Core configuration options
8 9 10 |
# File 'lib/rails_active_mcp/configuration.rb', line 8 def command_timeout @command_timeout end |
#custom_safety_patterns ⇒ Object
Returns the value of attribute custom_safety_patterns.
12 13 14 |
# File 'lib/rails_active_mcp/configuration.rb', line 12 def custom_safety_patterns @custom_safety_patterns end |
#enable_logging ⇒ Object
Core configuration options
8 9 10 |
# File 'lib/rails_active_mcp/configuration.rb', line 8 def enable_logging @enable_logging end |
#enabled ⇒ Object
Safety and execution options
11 12 13 |
# File 'lib/rails_active_mcp/configuration.rb', line 11 def enabled @enabled end |
#log_executions ⇒ Object
Safety and execution options
11 12 13 |
# File 'lib/rails_active_mcp/configuration.rb', line 11 def log_executions @log_executions end |
#log_level ⇒ Object
Core configuration options
8 9 10 |
# File 'lib/rails_active_mcp/configuration.rb', line 8 def log_level @log_level end |
#max_results ⇒ Object
Safety and execution options
11 12 13 |
# File 'lib/rails_active_mcp/configuration.rb', line 11 def max_results @max_results end |
#safe_mode ⇒ Object
Safety and execution options
11 12 13 |
# File 'lib/rails_active_mcp/configuration.rb', line 11 def safe_mode @safe_mode end |
Instance Method Details
#development_mode! ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/rails_active_mcp/configuration.rb', line 74 def development_mode! @safe_mode = false @log_level = :debug @command_timeout = 60 @max_results = 200 @log_executions = false end |
#model_allowed?(model_name) ⇒ Boolean
29 30 31 32 33 |
# File 'lib/rails_active_mcp/configuration.rb', line 29 def model_allowed?(model_name) return true if @allowed_models.empty? # Allow all if none specified @allowed_models.include?(model_name.to_s) end |
#production_mode! ⇒ Object
Environment-specific configuration presets
66 67 68 69 70 71 72 |
# File 'lib/rails_active_mcp/configuration.rb', line 66 def production_mode! @safe_mode = true @log_level = :warn @command_timeout = 15 @max_results = 50 @log_executions = true end |
#reset! ⇒ Object
61 62 63 |
# File 'lib/rails_active_mcp/configuration.rb', line 61 def reset! initialize end |
#test_mode! ⇒ Object
82 83 84 85 86 87 |
# File 'lib/rails_active_mcp/configuration.rb', line 82 def test_mode! @safe_mode = true @log_level = :error @command_timeout = 30 @log_executions = false end |
#valid? ⇒ Boolean
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rails_active_mcp/configuration.rb', line 35 def valid? command_timeout.is_a?(Numeric) && command_timeout > 0 && [true, false].include?(enable_logging) && %i[debug info warn error].include?(log_level) && [true, false].include?(safe_mode) && max_results.is_a?(Numeric) && max_results > 0 && [true, false].include?(log_executions) && custom_safety_patterns.is_a?(Array) && allowed_models.is_a?(Array) && [true, false].include?(enabled) end |
#validate? ⇒ Boolean
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rails_active_mcp/configuration.rb', line 47 def validate? raise ArgumentError, 'command_timeout must be positive' unless command_timeout.is_a?(Numeric) && command_timeout > 0 raise ArgumentError, 'log_level must be one of: debug, info, warn, error' unless %i[debug info warn error].include?(log_level) raise ArgumentError, 'safe_mode must be a boolean' unless [true, false].include?(safe_mode) raise ArgumentError, 'max_results must be positive' unless max_results.is_a?(Numeric) && max_results > 0 raise ArgumentError, 'enabled must be a boolean' unless [true, false].include?(enabled) true end |