Class: MCP::Client::OAuth::InMemoryStorage

Inherits:
Object
  • Object
show all
Defined in:
lib/mcp/client/oauth/in_memory_storage.rb

Overview

Default reference implementation of the storage contract that ‘Provider` uses to persist OAuth state. Holds the two pieces of data the flow saves and reads on every request:

  • ‘tokens`: the hash returned by the token endpoint (`access_token`, optional `refresh_token`, `expires_in`, `scope`, etc.).

  • ‘client_information`: the hash returned by Dynamic Client Registration or supplied as pre-registered credentials (`client_id`, optional `client_secret`, optional `token_endpoint_auth_method`).

This class keeps everything in process memory, so the credentials live only for the lifetime of the Ruby process. Applications that need persistence across restarts should supply a custom object responding to the same four-method contract (‘tokens`, `save_tokens(t)`, `client_information`, `save_client_information(info)`) and pass it via `Provider.new(storage: …)`. The shape mirrors Python SDK’s ‘TokenStorage` Protocol; TypeScript’s ‘OAuthClientProvider` rolls the same responsibilities into a single object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInMemoryStorage

Returns a new instance of InMemoryStorage.



28
29
30
31
# File 'lib/mcp/client/oauth/in_memory_storage.rb', line 28

def initialize
  @tokens = nil
  @client_information = nil
end

Instance Attribute Details

#client_informationObject

Returns the value of attribute client_information.



26
27
28
# File 'lib/mcp/client/oauth/in_memory_storage.rb', line 26

def client_information
  @client_information
end

#tokensObject

Returns the value of attribute tokens.



26
27
28
# File 'lib/mcp/client/oauth/in_memory_storage.rb', line 26

def tokens
  @tokens
end

Instance Method Details

#save_client_information(info) ⇒ Object



37
38
39
# File 'lib/mcp/client/oauth/in_memory_storage.rb', line 37

def save_client_information(info)
  @client_information = info
end

#save_tokens(tokens) ⇒ Object



33
34
35
# File 'lib/mcp/client/oauth/in_memory_storage.rb', line 33

def save_tokens(tokens)
  @tokens = tokens
end