Skip to content

Commit c3973cb

Browse files
committed
Fix Redis connection type conversion bug
- Fix set_redis_config_from_cli to preserve correct types for Redis connection parameters - Keep port and db as integers, ssl and cluster_mode as booleans - This resolves the issue where uvx commands would hang due to Redis connection failures - Re-enable Redis connection ping test in CLI Fixes issue where 'uvx --from /path redis-mcp-server --url redis://localhost:6379/0' would not show 'Starting the Redis MCP Server' message due to connection hanging.
1 parent dc02a5d commit c3973cb

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/common/config.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ def parse_redis_uri(uri: str) -> dict:
8585

8686
def set_redis_config_from_cli(config: dict):
8787
for key, value in config.items():
88-
if isinstance(value, bool):
89-
value = 'true' if value else 'false'
90-
REDIS_CFG[key] = str(value)
88+
if key in ['port', 'db']:
89+
# Keep port and db as integers
90+
REDIS_CFG[key] = int(value)
91+
elif key == 'ssl' or key == 'cluster_mode':
92+
# Keep ssl and cluster_mode as booleans
93+
REDIS_CFG[key] = bool(value)
94+
elif isinstance(value, bool):
95+
# Convert other booleans to strings for environment compatibility
96+
REDIS_CFG[key] = 'true' if value else 'false'
97+
else:
98+
# Convert other values to strings
99+
REDIS_CFG[key] = str(value) if value is not None else None

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def cli(url, host, port, db, username, password,
7878

7979
set_redis_config_from_cli(config)
8080

81-
# RedisConnectionManager.get_connection().ping()
81+
RedisConnectionManager.get_connection().ping()
8282

8383
# Start the server
8484
server = RedisMCPServer()

0 commit comments

Comments
 (0)