Class: Clacky::Mcp::OAuth::Config
- Inherits:
-
Object
- Object
- Clacky::Mcp::OAuth::Config
- Defined in:
- lib/clacky/mcp/oauth/config.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Class Method Summary collapse
Instance Method Summary collapse
- #enabled? ⇒ Boolean
-
#initialize(enabled:, resource:, endpoint: nil) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(enabled:, resource:, endpoint: nil) ⇒ Config
Returns a new instance of Config.
25 26 27 28 29 30 |
# File 'lib/clacky/mcp/oauth/config.rb', line 25 def initialize(enabled:, resource:, endpoint: nil) @enabled = enabled @resource = resource.to_s @endpoint = (endpoint || resource).to_s validate! if enabled? end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
11 12 13 |
# File 'lib/clacky/mcp/oauth/config.rb', line 11 def resource @resource end |
Class Method Details
.from_server_spec(spec) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/clacky/mcp/oauth/config.rb', line 13 def self.from_server_spec(spec) spec ||= {} auth = spec["auth"] enabled = auth.is_a?(Hash) && !auth.empty? if enabled && auth["type"].to_s != "oauth" raise Error, "unsupported MCP authentication type '#{auth['type']}'" end resource = enabled ? (auth["resource"] || spec["url"]) : spec["url"] new(enabled: enabled, resource: resource, endpoint: spec["url"]) end |
Instance Method Details
#enabled? ⇒ Boolean
32 33 34 |
# File 'lib/clacky/mcp/oauth/config.rb', line 32 def enabled? @enabled == true end |