Class: MCPClient::Auth::ServerMetadata

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

Overview

OAuth authorization server metadata

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(issuer:, authorization_endpoint:, token_endpoint:, registration_endpoint: nil, scopes_supported: nil, response_types_supported: nil, grant_types_supported: nil) ⇒ ServerMetadata



208
209
210
211
212
213
214
215
216
217
# File 'lib/mcp_client/auth.rb', line 208

def initialize(issuer:, authorization_endpoint:, token_endpoint:, registration_endpoint: nil,
               scopes_supported: nil, response_types_supported: nil, grant_types_supported: nil)
  @issuer = issuer
  @authorization_endpoint = authorization_endpoint
  @token_endpoint = token_endpoint
  @registration_endpoint = registration_endpoint
  @scopes_supported = scopes_supported
  @response_types_supported = response_types_supported
  @grant_types_supported = grant_types_supported
end

Instance Attribute Details

#authorization_endpointObject (readonly)

Returns the value of attribute authorization_endpoint.



198
199
200
# File 'lib/mcp_client/auth.rb', line 198

def authorization_endpoint
  @authorization_endpoint
end

#grant_types_supportedObject (readonly)

Returns the value of attribute grant_types_supported.



198
199
200
# File 'lib/mcp_client/auth.rb', line 198

def grant_types_supported
  @grant_types_supported
end

#issuerObject (readonly)

Returns the value of attribute issuer.



198
199
200
# File 'lib/mcp_client/auth.rb', line 198

def issuer
  @issuer
end

#registration_endpointObject (readonly)

Returns the value of attribute registration_endpoint.



198
199
200
# File 'lib/mcp_client/auth.rb', line 198

def registration_endpoint
  @registration_endpoint
end

#response_types_supportedObject (readonly)

Returns the value of attribute response_types_supported.



198
199
200
# File 'lib/mcp_client/auth.rb', line 198

def response_types_supported
  @response_types_supported
end

#scopes_supportedObject (readonly)

Returns the value of attribute scopes_supported.



198
199
200
# File 'lib/mcp_client/auth.rb', line 198

def scopes_supported
  @scopes_supported
end

#token_endpointObject (readonly)

Returns the value of attribute token_endpoint.



198
199
200
# File 'lib/mcp_client/auth.rb', line 198

def token_endpoint
  @token_endpoint
end

Class Method Details

.from_h(data) ⇒ ServerMetadata

Create server metadata from hash



242
243
244
245
246
247
248
249
250
251
252
# File 'lib/mcp_client/auth.rb', line 242

def self.from_h(data)
  new(
    issuer: data[:issuer] || data['issuer'],
    authorization_endpoint: data[:authorization_endpoint] || data['authorization_endpoint'],
    token_endpoint: data[:token_endpoint] || data['token_endpoint'],
    registration_endpoint: data[:registration_endpoint] || data['registration_endpoint'],
    scopes_supported: data[:scopes_supported] || data['scopes_supported'],
    response_types_supported: data[:response_types_supported] || data['response_types_supported'],
    grant_types_supported: data[:grant_types_supported] || data['grant_types_supported']
  )
end

Instance Method Details

#supports_registration?Boolean

Check if dynamic client registration is supported



221
222
223
# File 'lib/mcp_client/auth.rb', line 221

def supports_registration?
  !@registration_endpoint.nil?
end

#to_hHash

Convert to hash



227
228
229
230
231
232
233
234
235
236
237
# File 'lib/mcp_client/auth.rb', line 227

def to_h
  {
    issuer: @issuer,
    authorization_endpoint: @authorization_endpoint,
    token_endpoint: @token_endpoint,
    registration_endpoint: @registration_endpoint,
    scopes_supported: @scopes_supported,
    response_types_supported: @response_types_supported,
    grant_types_supported: @grant_types_supported
  }.compact
end