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



524
525
526
527
528
# File 'lib/mcp_client/auth.rb', line 524

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

Instance Attribute Details

#authorization_servers ⇒ Object (readonly)

Returns the value of attribute authorization_servers.



518
519
520
# File 'lib/mcp_client/auth.rb', line 518

def authorization_servers
  @authorization_servers
end

#resource ⇒ Object (readonly)

Returns the value of attribute resource.



518
519
520
# File 'lib/mcp_client/auth.rb', line 518

def resource
  @resource
end

#scopes_supported ⇒ Object (readonly)

Returns the value of attribute scopes_supported.



518
519
520
# File 'lib/mcp_client/auth.rb', line 518

def scopes_supported
  @scopes_supported
end

Class Method Details

.from_h(data) ⇒ ResourceMetadata

Create resource metadata from hash

Parameters:

  • data (Hash) —

    Resource metadata

Returns:



543
544
545
546
547
548
549
# File 'lib/mcp_client/auth.rb', line 543

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_h ⇒ Hash

Convert to hash

Returns:

  • (Hash) —

    Hash representation



532
533
534
535
536
537
538
# File 'lib/mcp_client/auth.rb', line 532

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