perf(mcp): URL-keyed connection pooling for Redis database tools#808
Merged
joshrotenberg merged 1 commit intomainfrom Mar 5, 2026
Merged
perf(mcp): URL-keyed connection pooling for Redis database tools#808joshrotenberg merged 1 commit intomainfrom
joshrotenberg merged 1 commit intomainfrom
Conversation
Add a connection cache to CachedClients (keyed by resolved URL) that returns a shared MultiplexedConnection, matching the existing pattern used for Cloud and Enterprise API clients. - Add `database: HashMap<String, MultiplexedConnection>` to CachedClients - Add `redis_connection_for_url()` on AppState with PING health check and automatic reconnect on stale connections - Add `get_connection()` helper in tools/redis/mod.rs that combines URL resolution and cached connection retrieval - Replace per-handler Client::open + get_multiplexed_async_connection boilerplate across all 55 database tool handlers Connections are keyed by URL (not profile name) so different profiles pointing to the same database share a connection, and raw URL callers benefit from caching too. Closes #801
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CachedClientskeyed by resolved URL, returning sharedMultiplexedConnectioninstancesredis_connection_for_url()onAppStatewith PING health check and automatic reconnect on stale connectionsget_connection()helper intools/redis/mod.rscombining URL resolution + cached connection retrievalClient::open+get_multiplexed_async_connectionboilerplate across all 55 database tool handlers (-496 lines net)Connections are keyed by URL (not profile name) so different profiles pointing to the same database share a connection, and raw URL callers benefit from caching too. Users with multiple database profiles get one cached connection per unique URL.
Follows the same
RwLock<HashMap>pattern already used for Cloud and Enterprise API client caching.Closes #801
Test plan
cargo clippy -p redisctl-mcp --all-features -- -D warnings(clean)cargo check -p redisctl-mcp --no-default-features(clean)cargo check -p redisctl-mcp --features database(clean)cargo check -p redisctl-mcp --features cloud(clean)cargo check -p redisctl-mcp --features enterprise(clean)cargo test --lib -p redisctl-mcp --all-features(95 passed)cargo fmt --all -- --check(clean)cargo test -p redisctl-mcp --test redis_tools --all-features -- --ignored(requires Docker)