Class: MCPClient::Auth::ResourceMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/mcp_client/auth.rb

Overview

Protected resource metadata for authorization server discovery

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource:, authorization_servers:, scopes_supported: nil) ⇒ ResourceMetadata

Returns a new instance of ResourceMetadata.

Parameters:

  • resource (String)

    Resource server identifier

  • authorization_servers (Array<String>)

    List of authorization server URLs

  • scopes_supported (Array<String>, nil) (defaults to: nil)

    Scopes the resource supports (RFC 9728); per MCP, the default scope set when a challenge provides none



325
326
327
328
329
# File 'lib/mcp_client/auth.rb', line 325

def initialize(resource:, authorization_servers:, scopes_supported: nil)
  @resource = resource
  @authorization_servers = authorization_servers
  @scopes_supported = scopes_supported
end

Instance Attribute Details

#authorization_serversObject (readonly)

Returns the value of attribute authorization_servers.



319
320
321
# File 'lib/mcp_client/auth.rb', line 319

def authorization_servers
  @authorization_servers
end

#resourceObject (readonly)

Returns the value of attribute resource.



319
320
321
# File 'lib/mcp_client/auth.rb', line 319

def resource
  @resource
end

#scopes_supportedObject (readonly)

Returns the value of attribute scopes_supported.



319
320
321
# File 'lib/mcp_client/auth.rb', line 319

def scopes_supported
  @scopes_supported
end

Class Method Details

.from_h(data) ⇒ ResourceMetadata

Create resource metadata from hash

Parameters:

  • data (Hash)

    Resource metadata

Returns:



344
345
346
347
348
349
350
# File 'lib/mcp_client/auth.rb', line 344

def self.from_h(data)
  new(
    resource: data[:resource] || data['resource'],
    authorization_servers: data[:authorization_servers] || data['authorization_servers'],
    scopes_supported: data[:scopes_supported] || data['scopes_supported']
  )
end

Instance Method Details

#to_hHash

Convert to hash

Returns:

  • (Hash)

    Hash representation



333
334
335
336
337
338
339
# File 'lib/mcp_client/auth.rb', line 333

def to_h
  {
    resource: @resource,
    authorization_servers: @authorization_servers,
    scopes_supported: @scopes_supported
  }.compact
end