Available Backends
In-Memory Storage
Best for: Development, testing, single-process deployments In-memory storage is the default for all FastMCP storage needs. It’s fast, requires no setup, and is perfect for getting started.- ✅ No setup required
- ✅ Very fast
- ❌ Data lost on restart
- ❌ Not suitable for multi-process deployments
File Storage
Best for: Single-server production deployments, persistent caching File storage persists data to the filesystem as one JSON file per key, allowing it to survive server restarts. This is the default backend for OAuth storage on Mac and Windows.- ✅ Data persists across restarts
- ✅ No external dependencies
- ✅ Human-readable files on disk
- ❌ Not suitable for distributed deployments
- ❌ Filesystem access required
Redis
Best for: Distributed production deployments, shared caching across multiple serversRedis support requires an optional dependency:
pip install 'py-key-value-aio[redis]'- ✅ Distributed and highly available
- ✅ Fast in-memory performance
- ✅ Works across multiple server instances
- ✅ Built-in TTL support
- ❌ Requires Redis infrastructure
- ❌ Network latency vs local storage
Other Backends from py-key-value-aio
The py-key-value-aio library includes additional implementations for various storage systems:- DynamoDB - AWS distributed database
- MongoDB - NoSQL document store
- Elasticsearch - Distributed search and analytics
- Memcached - Distributed memory caching
- RocksDB - Embedded high-performance key-value store
- Valkey - Redis-compatible server
Use Cases in FastMCP
Server-Side OAuth Token Storage
The OAuth Proxy and OAuth auth providers use storage for persisting OAuth client registrations and upstream tokens. By default, storage is automatically encrypted usingFernetEncryptionWrapper. When providing custom storage, wrap it in FernetEncryptionWrapper to encrypt sensitive OAuth tokens at rest.
Development (default behavior):
By default, FastMCP automatically manages keys and storage based on your platform:
- Mac/Windows: Keys are auto-managed via system keyring, storage defaults to disk. Suitable only for development and local testing.
- Linux: Keys are ephemeral, storage defaults to memory.
FernetEncryptionWrapper to encrypt sensitive OAuth tokens at rest - without it, tokens are stored in plaintext. See OAuth Token Security and Key and Storage Management for complete setup details.
Response Caching Middleware
The Response Caching Middleware caches tool calls, resource reads, and prompt requests. Storage configuration is passed via thecache_storage parameter:
Client-Side OAuth Token Storage
The FastMCP Client uses storage for persisting OAuth tokens locally. By default, tokens are stored in memory:Choosing a Backend
Decision tree:
- Just starting? Use Memory (default) - no configuration needed
- Single server, needs persistence? Use File
- Multiple servers or cloud deployment? Use Redis or DynamoDB
- Existing infrastructure? Look for a matching py-key-value-aio backend
More Resources
- py-key-value-aio GitHub - Full library documentation
- Response Caching Middleware - Using storage for caching
- OAuth Token Security - Production OAuth configuration
- HTTP Deployment - Complete deployment guide

