Skip to content

Commit 962787c

Browse files
committed
Changed parameter names, removed generate_redis_url function
1 parent 5d08398 commit 962787c

File tree

4 files changed

+91
-104
lines changed

4 files changed

+91
-104
lines changed

README.md

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,20 @@ Additional tools.
4141

4242
### Quick Start with uvx (Recommended)
4343

44-
The easiest way to use the Redis MCP Server is with `uvx`, which allows you to run it directly without installation:
44+
The easiest way to use the Redis MCP Server is with `uvx`, which allows you to run it directly from GitHub without installation:
4545

4646
```sh
4747
# Run with Redis URI
48-
uvx redis-mcp-server --redis-uri redis://localhost:6379/0
48+
uvx --from git+https://github.com/redis/mcp-redis.git@feature/uvx-cli-support redis-mcp-server --url redis://localhost:6379/0
4949

5050
# Run with individual parameters
51-
uvx redis-mcp-server --redis-host localhost --redis-port 6379 --redis-password mypassword
51+
uvx --from git+https://github.com/redis/mcp-redis.git@feature/uvx-cli-support redis-mcp-server --host localhost --port 6379 --password mypassword
5252

5353
# Run with SSL
54-
uvx redis-mcp-server --redis-uri rediss://user:[email protected]:6380/0
54+
uvx --from git+https://github.com/redis/mcp-redis.git@feature/uvx-cli-support redis-mcp-server --url rediss://user:[email protected]:6380/0
5555

5656
# See all options
57-
uvx redis-mcp-server --help
57+
uvx --from git+https://github.com/redis/mcp-redis.git@feature/uvx-cli-support redis-mcp-server --help
5858
```
5959

6060
### Development Installation
@@ -71,31 +71,60 @@ uv venv
7171
source .venv/bin/activate
7272
uv sync
7373

74-
# Run locally during development
74+
# Run with CLI interface (recommended)
7575
uv run redis-mcp-server --help
76-
```
7776

78-
### Publishing to PyPI
77+
# Or run the main file directly (uses environment variables)
78+
uv run src/main.py
79+
```
7980

80-
To publish the package to PyPI for global `uvx` usage:
81+
## Configuration
8182

82-
```sh
83-
# Build the package
84-
uv build
83+
The Redis MCP Server can be configured in two ways: via command line arguments (recommended) or environment variables.
8584

86-
# Publish to PyPI (requires PyPI credentials)
87-
uv publish
88-
```
85+
### Configuration via Command Line (Recommended)
8986

90-
Once published, users can run it globally with:
87+
When using the CLI interface, you can configure the server with command line arguments:
9188

9289
```sh
93-
uvx redis-mcp-server --redis-uri redis://localhost:6379/0
90+
# Basic Redis connection
91+
uvx --from git+https://github.com/redis/mcp-redis.git@feature/uvx-cli-support redis-mcp-server \
92+
--host localhost \
93+
--port 6379 \
94+
--password mypassword
95+
96+
# Using Redis URI (simpler)
97+
uvx --from git+https://github.com/redis/mcp-redis.git@feature/uvx-cli-support redis-mcp-server \
98+
--url redis://user:pass@localhost:6379/0
99+
100+
# SSL connection
101+
uvx --from git+https://github.com/redis/mcp-redis.git@feature/uvx-cli-support redis-mcp-server \
102+
--url rediss://user:[email protected]:6380/0 \
103+
--ssl-ca-path /path/to/ca.pem
104+
105+
# See all available options
106+
uvx --from git+https://github.com/redis/mcp-redis.git@feature/uvx-cli-support redis-mcp-server --help
94107
```
95108

96-
## Configuration
97-
98-
To configure this Redis MCP Server, consider the following environment variables:
109+
**Available CLI Options:**
110+
- `--url` - Redis connection URI (redis://user:pass@host:port/db)
111+
- `--host` - Redis hostname (default: 127.0.0.1)
112+
- `--port` - Redis port (default: 6379)
113+
- `--db` - Redis database number (default: 0)
114+
- `--username` - Redis username
115+
- `--password` - Redis password
116+
- `--ssl` - Enable SSL connection
117+
- `--ssl-ca-path` - Path to CA certificate file
118+
- `--ssl-keyfile` - Path to SSL key file
119+
- `--ssl-certfile` - Path to SSL certificate file
120+
- `--cluster-mode` - Enable Redis cluster mode
121+
- `--mcp-transport` - MCP transport method (stdio, streamable-http, sse)
122+
- `--mcp-host` - MCP server host (default: 127.0.0.1)
123+
- `--mcp-port` - MCP server port (default: 8000)
124+
125+
### Configuration via Environment Variables
126+
127+
When running the server directly (`uv run src/main.py`) or for legacy compatibility, you can use environment variables:
99128

100129
| Name | Description | Default Value |
101130
|----------------------|-----------------------------------------------------------|---------------|
@@ -248,7 +277,7 @@ Add this to your `claude_desktop_config.json`:
248277
"command": "uvx",
249278
"args": [
250279
"redis-mcp-server",
251-
"--redis-uri", "redis://localhost:6379/0"
280+
"--url", "redis://localhost:6379/0"
252281
]
253282
}
254283
}
@@ -264,9 +293,9 @@ Or with individual parameters:
264293
"command": "uvx",
265294
"args": [
266295
"redis-mcp-server",
267-
"--redis-host", "your-redis-host",
268-
"--redis-port", "6379",
269-
"--redis-password", "your-password"
296+
"--host", "your-redis-host",
297+
"--port", "6379",
298+
"--password", "your-password"
270299
]
271300
}
272301
}
@@ -285,7 +314,7 @@ Add this to your `.vscode/mcp.json`:
285314
"command": "uvx",
286315
"args": [
287316
"redis-mcp-server",
288-
"--redis-uri", "redis://localhost:6379/0"
317+
"--url", "redis://localhost:6379/0"
289318
]
290319
}
291320
}

src/common/config.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import urllib
21
from dotenv import load_dotenv
32
import os
43

@@ -22,42 +21,3 @@
2221
"db": int(os.getenv('REDIS_DB', 0))}
2322

2423

25-
def generate_redis_uri():
26-
cfg = REDIS_CFG
27-
scheme = "rediss" if cfg.get("ssl") else "redis"
28-
host = cfg.get("host", "127.0.0.1")
29-
port = cfg.get("port", 6379)
30-
db = cfg.get("db", 0)
31-
32-
username = cfg.get("username")
33-
password = cfg.get("password")
34-
35-
# Auth part
36-
if username:
37-
auth_part = f"{urllib.parse.quote(username)}:{urllib.parse.quote(password)}@"
38-
elif password:
39-
auth_part = f":{urllib.parse.quote(password)}@"
40-
else:
41-
auth_part = ""
42-
43-
# Base URI
44-
base_uri = f"{scheme}://{auth_part}{host}:{port}/{db}"
45-
46-
# Additional SSL query parameters if SSL is enabled
47-
query_params = {}
48-
if cfg.get("ssl"):
49-
if cfg.get("ssl_cert_reqs"):
50-
query_params["ssl_cert_reqs"] = cfg["ssl_cert_reqs"]
51-
if cfg.get("ssl_ca_certs"):
52-
query_params["ssl_ca_certs"] = cfg["ssl_ca_certs"]
53-
if cfg.get("ssl_keyfile"):
54-
query_params["ssl_keyfile"] = cfg["ssl_keyfile"]
55-
if cfg.get("ssl_certfile"):
56-
query_params["ssl_certfile"] = cfg["ssl_certfile"]
57-
if cfg.get("ssl_ca_path"):
58-
query_params["ssl_ca_path"] = cfg["ssl_ca_path"]
59-
60-
if query_params:
61-
base_uri += "?" + urllib.parse.urlencode(query_params)
62-
63-
return base_uri

src/common/connection.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
from typing import Optional, Type, Union
77
from src.common.config import REDIS_CFG
88

9-
from src.common.config import generate_redis_uri
10-
119

1210
class RedisConnectionManager:
1311
_instance: Optional[Redis] = None

src/main.py

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -88,60 +88,60 @@ def set_redis_env_from_config(config: dict):
8888

8989

9090
@click.command()
91-
@click.option('--redis-uri', help='Redis connection URI (redis://user:pass@host:port/db or rediss:// for SSL)')
92-
@click.option('--redis-host', default='127.0.0.1', help='Redis host')
93-
@click.option('--redis-port', default=6379, type=int, help='Redis port')
94-
@click.option('--redis-db', default=0, type=int, help='Redis database number')
95-
@click.option('--redis-username', help='Redis username')
96-
@click.option('--redis-password', help='Redis password')
97-
@click.option('--redis-ssl', is_flag=True, help='Use SSL connection')
98-
@click.option('--redis-ssl-ca-path', help='Path to CA certificate file')
99-
@click.option('--redis-ssl-keyfile', help='Path to SSL key file')
100-
@click.option('--redis-ssl-certfile', help='Path to SSL certificate file')
101-
@click.option('--redis-ssl-cert-reqs', default='required', help='SSL certificate requirements')
102-
@click.option('--redis-ssl-ca-certs', help='Path to CA certificates file')
103-
@click.option('--redis-cluster-mode', is_flag=True, help='Enable Redis cluster mode')
91+
@click.option('--url', help='Redis connection URI (redis://user:pass@host:port/db or rediss:// for SSL)')
92+
@click.option('--host', default='127.0.0.1', help='Redis host')
93+
@click.option('--port', default=6379, type=int, help='Redis port')
94+
@click.option('--db', default=0, type=int, help='Redis database number')
95+
@click.option('--username', help='Redis username')
96+
@click.option('--password', help='Redis password')
97+
@click.option('--ssl', is_flag=True, help='Use SSL connection')
98+
@click.option('--ssl-ca-path', help='Path to CA certificate file')
99+
@click.option('--ssl-keyfile', help='Path to SSL key file')
100+
@click.option('--ssl-certfile', help='Path to SSL certificate file')
101+
@click.option('--ssl-cert-reqs', default='required', help='SSL certificate requirements')
102+
@click.option('--ssl-ca-certs', help='Path to CA certificates file')
103+
@click.option('--cluster-mode', is_flag=True, help='Enable Redis cluster mode')
104104
@click.option('--mcp-transport', default='stdio', type=click.Choice(['stdio', 'streamable-http', 'sse']), help='MCP transport method')
105105
@click.option('--mcp-host', default='127.0.0.1', help='MCP server host (for http/sse transport)')
106106
@click.option('--mcp-port', default=8000, type=int, help='MCP server port (for http/sse transport)')
107-
def cli(redis_uri, redis_host, redis_port, redis_db, redis_username, redis_password,
108-
redis_ssl, redis_ssl_ca_path, redis_ssl_keyfile, redis_ssl_certfile,
109-
redis_ssl_cert_reqs, redis_ssl_ca_certs, redis_cluster_mode,
107+
def cli(url, host, port, db, username, password,
108+
ssl, ssl_ca_path, ssl_keyfile, ssl_certfile,
109+
ssl_cert_reqs, ssl_ca_certs, cluster_mode,
110110
mcp_transport, mcp_host, mcp_port):
111111
"""Redis MCP Server - Model Context Protocol server for Redis."""
112112

113113
# Handle Redis URI if provided
114-
if redis_uri:
114+
if url:
115115
try:
116-
uri_config = parse_redis_uri(redis_uri)
116+
uri_config = parse_redis_uri(url)
117117
set_redis_env_from_config(uri_config)
118118
except ValueError as e:
119119
click.echo(f"Error parsing Redis URI: {e}", err=True)
120120
sys.exit(1)
121121
else:
122122
# Set individual Redis parameters
123123
config = {
124-
'host': redis_host,
125-
'port': redis_port,
126-
'db': redis_db,
127-
'ssl': redis_ssl,
128-
'cluster_mode': redis_cluster_mode
124+
'host': host,
125+
'port': port,
126+
'db': db,
127+
'ssl': ssl,
128+
'cluster_mode': cluster_mode
129129
}
130130

131-
if redis_username:
132-
config['username'] = redis_username
133-
if redis_password:
134-
config['password'] = redis_password
135-
if redis_ssl_ca_path:
136-
config['ssl_ca_path'] = redis_ssl_ca_path
137-
if redis_ssl_keyfile:
138-
config['ssl_keyfile'] = redis_ssl_keyfile
139-
if redis_ssl_certfile:
140-
config['ssl_certfile'] = redis_ssl_certfile
141-
if redis_ssl_cert_reqs:
142-
config['ssl_cert_reqs'] = redis_ssl_cert_reqs
143-
if redis_ssl_ca_certs:
144-
config['ssl_ca_certs'] = redis_ssl_ca_certs
131+
if username:
132+
config['username'] = username
133+
if password:
134+
config['password'] = password
135+
if ssl_ca_path:
136+
config['ssl_ca_path'] = ssl_ca_path
137+
if ssl_keyfile:
138+
config['ssl_keyfile'] = ssl_keyfile
139+
if ssl_certfile:
140+
config['ssl_certfile'] = ssl_certfile
141+
if ssl_cert_reqs:
142+
config['ssl_cert_reqs'] = ssl_cert_reqs
143+
if ssl_ca_certs:
144+
config['ssl_ca_certs'] = ssl_ca_certs
145145

146146
set_redis_env_from_config(config)
147147

0 commit comments

Comments
 (0)