Class: McpOnRuby::Configuration
- Inherits:
-
Object
- Object
- McpOnRuby::Configuration
- Defined in:
- lib/mcp_on_ruby/configuration.rb
Overview
Configuration class for MCP server
Instance Attribute Summary collapse
-
#allowed_origins ⇒ Object
Returns the value of attribute allowed_origins.
-
#authentication_required ⇒ Object
Returns the value of attribute authentication_required.
-
#authentication_token ⇒ Object
Returns the value of attribute authentication_token.
-
#cors_enabled ⇒ Object
Returns the value of attribute cors_enabled.
-
#dns_rebinding_protection ⇒ Object
Returns the value of attribute dns_rebinding_protection.
-
#enable_sse ⇒ Object
Returns the value of attribute enable_sse.
-
#localhost_only ⇒ Object
Returns the value of attribute localhost_only.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#path ⇒ Object
Returns the value of attribute path.
-
#rate_limit_per_minute ⇒ Object
Returns the value of attribute rate_limit_per_minute.
-
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
Instance Method Summary collapse
-
#authentication_configured? ⇒ Boolean
Check if authentication is configured.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#localhost_allowed?(origin) ⇒ Boolean
Check if localhost only mode and origin is localhost.
-
#origin_allowed?(origin) ⇒ Boolean
Check if origin is allowed.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mcp_on_ruby/configuration.rb', line 20 def initialize @log_level = Logger::INFO @path = '/mcp' @authentication_required = false @authentication_token = nil @allowed_origins = [] @localhost_only = false @rate_limit_per_minute = 60 @enable_sse = true @request_timeout = 30 @cors_enabled = true @dns_rebinding_protection = true end |
Instance Attribute Details
#allowed_origins ⇒ Object
Returns the value of attribute allowed_origins.
8 9 10 |
# File 'lib/mcp_on_ruby/configuration.rb', line 8 def allowed_origins @allowed_origins end |
#authentication_required ⇒ Object
Returns the value of attribute authentication_required.
8 9 10 |
# File 'lib/mcp_on_ruby/configuration.rb', line 8 def authentication_required @authentication_required end |
#authentication_token ⇒ Object
Returns the value of attribute authentication_token.
8 9 10 |
# File 'lib/mcp_on_ruby/configuration.rb', line 8 def authentication_token @authentication_token end |
#cors_enabled ⇒ Object
Returns the value of attribute cors_enabled.
8 9 10 |
# File 'lib/mcp_on_ruby/configuration.rb', line 8 def cors_enabled @cors_enabled end |
#dns_rebinding_protection ⇒ Object
Returns the value of attribute dns_rebinding_protection.
8 9 10 |
# File 'lib/mcp_on_ruby/configuration.rb', line 8 def dns_rebinding_protection @dns_rebinding_protection end |
#enable_sse ⇒ Object
Returns the value of attribute enable_sse.
8 9 10 |
# File 'lib/mcp_on_ruby/configuration.rb', line 8 def enable_sse @enable_sse end |
#localhost_only ⇒ Object
Returns the value of attribute localhost_only.
8 9 10 |
# File 'lib/mcp_on_ruby/configuration.rb', line 8 def localhost_only @localhost_only end |
#log_level ⇒ Object
Returns the value of attribute log_level.
8 9 10 |
# File 'lib/mcp_on_ruby/configuration.rb', line 8 def log_level @log_level end |
#path ⇒ Object
Returns the value of attribute path.
8 9 10 |
# File 'lib/mcp_on_ruby/configuration.rb', line 8 def path @path end |
#rate_limit_per_minute ⇒ Object
Returns the value of attribute rate_limit_per_minute.
8 9 10 |
# File 'lib/mcp_on_ruby/configuration.rb', line 8 def rate_limit_per_minute @rate_limit_per_minute end |
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
8 9 10 |
# File 'lib/mcp_on_ruby/configuration.rb', line 8 def request_timeout @request_timeout end |
Instance Method Details
#authentication_configured? ⇒ Boolean
Check if authentication is configured
36 37 38 |
# File 'lib/mcp_on_ruby/configuration.rb', line 36 def authentication_configured? authentication_required && !authentication_token.nil? end |
#localhost_allowed?(origin) ⇒ Boolean
Check if localhost only mode and origin is localhost
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/mcp_on_ruby/configuration.rb', line 61 def localhost_allowed?(origin) return true unless localhost_only localhost_patterns = [ 'http://localhost', 'https://localhost', 'http://127.0.0.1', 'https://127.0.0.1' ] localhost_patterns.any? { |pattern| origin&.start_with?(pattern) } end |
#origin_allowed?(origin) ⇒ Boolean
Check if origin is allowed
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/mcp_on_ruby/configuration.rb', line 43 def origin_allowed?(origin) return true if allowed_origins.empty? allowed_origins.any? do |allowed| case allowed when String origin == allowed when Regexp origin =~ allowed else false end end end |