Redis caching is completely optional. The UniFi MCP Server works without Redis; every tool call simply fetches data directly from the UniFi API. You only need Redis if you want faster responses and fewer API calls.
When to use caching
Caching is most beneficial when:- Your network has a large number of devices or clients (50+)
- Multiple AI sessions are running simultaneously
- You are using the Cloud Early Access API, which has a 100 requests/minute rate limit
- Tools that read the same data frequently (device lists, site statistics) are called many times per session
Configuration variables
Add the following to your.env file to enable Redis:
If Redis is configured but unavailable when the server starts, caching is automatically disabled for that session and a warning is logged. The server continues to work normally without cache.
TTL (time-to-live) by resource type
Different resource types have different TTLs based on how frequently they change:Automatic cache invalidation
When you use a mutating tool—such ascreate_network, update_wlan, or restart_device—the server automatically invalidates the relevant cache entries for that site. This means you always see current data after making a change, without needing to wait for the TTL to expire.
Webhook events also trigger cache invalidation. When a device goes offline or a client disconnects, the associated cache entries are purged immediately so the next query reflects the real state of your network.
Docker Compose example with Redis
The recommended way to run the MCP server with Redis is with Docker Compose. Add a Redis service alongside the MCP server:redis as the hostname, which Docker Compose resolves automatically.
Verifying the cache is working
When Redis caching is active, the server logs cache hits and misses at theDEBUG level. Set MCP_LOG_LEVEL=DEBUG in your environment to see entries like: