Features
- Abstract base class defining a consistent interface for credential stores
- Multiple storage backend implementations:
- In-memory store (temporary storage)
- Environment variable store
- System keyring store (secure credential storage)
- Exception handling for common error cases
- Type hints and comprehensive documentation
When to Use Each Store
Choose the store type that best fits your environment and security needs:- MemoryStore: Use for testing or temporary storage. Data is lost when the program exits.
- EnvironmentStore: Ideal for CI/CD pipelines or containerized environments where environment variables are managed externally.
- KeyringStore: Recommended for production and local development when you need secure, persistent storage using the system keyring.
Available Store Types
MemoryStore
A simple in-memory store that persists data only for the duration of program execution. Useful for testing or temporary storage.EnvironmentStore
Uses environment variables to store and retrieve credentials. Useful for containerized environments or CI/CD pipelines.KeyringStore
Leverages the system’s secure credential storage facility. Provides the most secure option for storing sensitive data.Getting Started
Here’s how to use a store to set and retrieve a credential:EnvironmentStore or KeyringStore by importing and instantiating the relevant class.
Best Practices
- Use KeyringStore for production environments where security is a priority.
- Use EnvironmentStore for containerized or cloud environments.
- Use MemoryStore for testing or temporary storage only.
- Always handle
StoreErrorandKeyNotFoundErrorexceptions appropriately.
Error Handling
The store module provides specific exceptions:StoreError: Base exception for all store-related errors.KeyNotFoundError: Raised when a requested key is not found.
Dependencies
keyring: Required for the KeyringStore implementationloguru: Used for logging operations in the KeyringStore
Contributing
To add a new store implementation, inherit fromBaseStore and implement all required abstract methods:
get(key: str) -> Anyset(key: str, value: str) -> Nonedelete(key: str) -> None
For a comprehensive guide, see the Universal MCP Stores Reference below.