Class: RubyLLM::MCP::Auth::ServerMetadata

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

Overview

OAuth Authorization Server Metadata (RFC 8414)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(issuer:, authorization_endpoint:, token_endpoint:, options: {}) ⇒ ServerMetadata

Returns a new instance of ServerMetadata.



219
220
221
222
223
224
225
226
227
228
229
# File 'lib/ruby_llm/mcp/auth.rb', line 219

def initialize(issuer:, authorization_endpoint:, token_endpoint:, options: {})
  @issuer = issuer
  @authorization_endpoint = authorization_endpoint
  @token_endpoint = token_endpoint
  @registration_endpoint = options[:registration_endpoint] || options["registration_endpoint"]
  @scopes_supported = options[:scopes_supported] || options["scopes_supported"]
  @response_types_supported = options[:response_types_supported] || options["response_types_supported"]
  @grant_types_supported = options[:grant_types_supported] || options["grant_types_supported"]
  @code_challenge_methods_supported = options[:code_challenge_methods_supported] ||
                                      options["code_challenge_methods_supported"]
end

Instance Attribute Details

#authorization_endpointObject (readonly)

Returns the value of attribute authorization_endpoint.



215
216
217
# File 'lib/ruby_llm/mcp/auth.rb', line 215

def authorization_endpoint
  @authorization_endpoint
end

#code_challenge_methods_supportedObject (readonly)

Returns the value of attribute code_challenge_methods_supported.



215
216
217
# File 'lib/ruby_llm/mcp/auth.rb', line 215

def code_challenge_methods_supported
  @code_challenge_methods_supported
end

#grant_types_supportedObject (readonly)

Returns the value of attribute grant_types_supported.



215
216
217
# File 'lib/ruby_llm/mcp/auth.rb', line 215

def grant_types_supported
  @grant_types_supported
end

#issuerObject (readonly)

Returns the value of attribute issuer.



215
216
217
# File 'lib/ruby_llm/mcp/auth.rb', line 215

def issuer
  @issuer
end

#registration_endpointObject (readonly)

Returns the value of attribute registration_endpoint.



215
216
217
# File 'lib/ruby_llm/mcp/auth.rb', line 215

def registration_endpoint
  @registration_endpoint
end

#response_types_supportedObject (readonly)

Returns the value of attribute response_types_supported.



215
216
217
# File 'lib/ruby_llm/mcp/auth.rb', line 215

def response_types_supported
  @response_types_supported
end

#scopes_supportedObject (readonly)

Returns the value of attribute scopes_supported.



215
216
217
# File 'lib/ruby_llm/mcp/auth.rb', line 215

def scopes_supported
  @scopes_supported
end

#token_endpointObject (readonly)

Returns the value of attribute token_endpoint.



215
216
217
# File 'lib/ruby_llm/mcp/auth.rb', line 215

def token_endpoint
  @token_endpoint
end

Class Method Details

.from_h(data) ⇒ ServerMetadata

Deserialize from hash

Parameters:

  • data (Hash)

    server metadata

Returns:



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/ruby_llm/mcp/auth.rb', line 255

def self.from_h(data)
  options = {
    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"],
    code_challenge_methods_supported:
      data[:code_challenge_methods_supported] || data["code_challenge_methods_supported"]
  }.compact

  new(
    issuer: data[:issuer] || data["issuer"],
    authorization_endpoint: data[:authorization_endpoint] || data["authorization_endpoint"],
    token_endpoint: data[:token_endpoint] || data["token_endpoint"],
    options: options
  )
end

Instance Method Details

#supports_registration?Boolean

Check if dynamic client registration is supported

Returns:

  • (Boolean)

    true if registration endpoint exists



233
234
235
# File 'lib/ruby_llm/mcp/auth.rb', line 233

def supports_registration?
  !@registration_endpoint.nil?
end

#to_hHash

Serialize to hash

Returns:

  • (Hash)

    server metadata



239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/ruby_llm/mcp/auth.rb', line 239

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,
    code_challenge_methods_supported: @code_challenge_methods_supported
  }.compact
end