Class: RubyLLM::MCP::Auth::Discoverer
- Inherits:
-
Object
- Object
- RubyLLM::MCP::Auth::Discoverer
- Defined in:
- lib/ruby_llm/mcp/auth/discoverer.rb
Overview
Service for discovering OAuth authorization servers Implements RFC 8414 (Server Metadata) and RFC 9728 (Protected Resource Metadata)
Instance Attribute Summary collapse
-
#http_client ⇒ Object
readonly
Returns the value of attribute http_client.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
-
#discover(server_url, resource_metadata_url: nil) ⇒ ServerMetadata?
Discover OAuth authorization server Tries two patterns: server as own auth server, or delegated auth server.
-
#initialize(http_client, storage, logger) ⇒ Discoverer
constructor
A new instance of Discoverer.
Constructor Details
#initialize(http_client, storage, logger) ⇒ Discoverer
Returns a new instance of Discoverer.
11 12 13 14 15 |
# File 'lib/ruby_llm/mcp/auth/discoverer.rb', line 11 def initialize(http_client, storage, logger) @http_client = http_client @storage = storage @logger = logger end |
Instance Attribute Details
#http_client ⇒ Object (readonly)
Returns the value of attribute http_client.
9 10 11 |
# File 'lib/ruby_llm/mcp/auth/discoverer.rb', line 9 def http_client @http_client end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
9 10 11 |
# File 'lib/ruby_llm/mcp/auth/discoverer.rb', line 9 def logger @logger end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
9 10 11 |
# File 'lib/ruby_llm/mcp/auth/discoverer.rb', line 9 def storage @storage end |
Instance Method Details
#discover(server_url, resource_metadata_url: nil) ⇒ ServerMetadata?
Discover OAuth authorization server Tries two patterns: server as own auth server, or delegated auth server
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ruby_llm/mcp/auth/discoverer.rb', line 22 def discover(server_url, resource_metadata_url: nil) logger.debug("Discovering OAuth authorization server for #{server_url}") cached = storage.(server_url) return cached if cached && .nil? # Prefer protected resource metadata discovery to follow MCP authorization rules, # then fall back to direct auth server metadata discovery for compatibility. = try_protected_resource_discovery(server_url, resource_metadata_url: ) ||= (server_url) ||= (server_url) ||= cached ||= (server_url) # Cache and return storage.(server_url, ) if end |