The BaseStore Interface
All credential stores in Universal MCP inherit from the BaseStore abstract base class (defined in stores/store.py). This ensures a consistent API for interacting with different storage backends. The core methods are:
get(self, key: str) -> Any: Retrieve a value (credential) from the store by its key. RaisesKeyNotFoundErrorif the key isn’t found.set(self, key: str, value: str) -> None: Store a value under the given key.delete(self, key: str) -> None: Delete a value from the store by its key. RaisesKeyNotFoundErrorif the key isn’t found.
Available Store Implementations
Universal MCP comes with several built-in store implementations:-
MemoryStore:- Description: An in-memory dictionary. Credentials stored here persist only for the duration of the program’s execution.
- Use Case: Excellent for testing, quick examples, or scenarios where persistent storage is not required or desired.
- Configuration (
type):"memory"
-
EnvironmentStore:- Description: Uses operating system environment variables to store and retrieve credentials.
- Use Case: Suitable for containerized environments (Docker, Kubernetes), CI/CD pipelines, or PaaS deployments where environment variables are the standard way to inject configuration and secrets.
- Configuration (
type):"environment"
-
KeyringStore:- Description: Leverages the system’s native secure credential storage facility (e.g., macOS Keychain, Windows Credential Manager, Linux Secret Service / KWallet). It uses the
keyringPython library. - Use Case: The most secure option for storing sensitive data on a user’s machine or a server where system-level secure storage is available and appropriate. Ideal for desktop applications or long-running services.
- Configuration (
type):"keyring" - Requires: The
keyringpackage (pip install keyring).
TheKeyringStoretakes anapp_nameargument during initialization (defaults to “universal_mcp”), which corresponds to the “service name” used in the system’s keychain. - Description: Leverages the system’s native secure credential storage facility (e.g., macOS Keychain, Windows Credential Manager, Linux Secret Service / KWallet). It uses the
Configuring Stores
You can configure stores in two main places:-
Globally in
ServerConfig: Thestorefield inServerConfigdefines the default store for the server.If anAppConfigdoesn’t specify its own store, this default server store will be used for itsIntegration. -
Specifically in
IntegrationConfig(withinAppConfig): You can override the default server store or specify a store for a particular integration.
store_from_config utility function is used internally to create the appropriate store instance based on the StoreConfig object.
Best Practices
- Use
KeyringStorefor production or sensitive user-specific credentials on local machines. - Use
EnvironmentStorefor server-side deployments and CI/CD. - Use
MemoryStoreprimarily for testing or transient data. - Always handle
KeyNotFoundErrorand otherStoreErrorexceptions when directly interacting with stores.