Module: RubyLLM::MCP::Auth

Defined in:
lib/ruby_llm/mcp/auth.rb,
lib/ruby_llm/mcp/auth/security.rb,
lib/ruby_llm/mcp/auth/discoverer.rb,
lib/ruby_llm/mcp/auth/url_builder.rb,
lib/ruby_llm/mcp/auth/browser/pages.rb,
lib/ruby_llm/mcp/auth/token_manager.rb,
lib/ruby_llm/mcp/auth/browser/opener.rb,
lib/ruby_llm/mcp/auth/memory_storage.rb,
lib/ruby_llm/mcp/auth/oauth_provider.rb,
lib/ruby_llm/mcp/auth/session_manager.rb,
lib/ruby_llm/mcp/auth/client_registrar.rb,
lib/ruby_llm/mcp/auth/browser/http_server.rb,
lib/ruby_llm/mcp/auth/grant_strategies/base.rb,
lib/ruby_llm/mcp/auth/http_response_handler.rb,
lib/ruby_llm/mcp/auth/browser_oauth_provider.rb,
lib/ruby_llm/mcp/auth/transport_oauth_helper.rb,
lib/ruby_llm/mcp/auth/browser/callback_server.rb,
lib/ruby_llm/mcp/auth/browser/callback_handler.rb,
lib/ruby_llm/mcp/auth/flows/authorization_code_flow.rb,
lib/ruby_llm/mcp/auth/flows/client_credentials_flow.rb,
lib/ruby_llm/mcp/auth/grant_strategies/authorization_code.rb,
lib/ruby_llm/mcp/auth/grant_strategies/client_credentials.rb

Defined Under Namespace

Modules: Browser, Flows, GrantStrategies, Security, TransportOauthHelper Classes: BrowserOAuthProvider, ClientInfo, ClientMetadata, ClientRegistrar, Discoverer, HttpResponseHandler, MemoryStorage, OAuthProvider, PKCE, ResourceMetadata, ServerMetadata, SessionManager, Token, TokenManager, UrlBuilder

Constant Summary collapse

TOKEN_REFRESH_BUFFER =

OAuth configuration constants Token refresh buffer time in seconds (5 minutes)

300
DEFAULT_OAUTH_TIMEOUT =

Default OAuth timeout in seconds (30 seconds)

30
CSRF_STATE_SIZE =

CSRF state parameter size in bytes (32 bytes)

32
PKCE_VERIFIER_SIZE =

PKCE code verifier size in bytes (32 bytes)

32

Class Method Summary collapse

Class Method Details

.create_oauth(server_url, type: :standard, **options) ⇒ OAuthProvider, BrowserOAuthProvider

Factory method to create OAuth providers

Parameters:

  • server_url (String)

    OAuth server URL

  • type (Symbol) (defaults to: :standard)

    OAuth provider type (:standard or :browser)

  • options (Hash)

    additional options passed to provider

Returns:



359
360
361
362
363
364
365
366
367
368
# File 'lib/ruby_llm/mcp/auth.rb', line 359

def self.create_oauth(server_url, type: :standard, **options)
  case type
  when :browser
    BrowserOAuthProvider.new(server_url: server_url, **options)
  when :standard
    OAuthProvider.new(server_url: server_url, **options)
  else
    raise ArgumentError, "Unknown OAuth type: #{type}. Must be :standard or :browser"
  end
end