@futuretea/redis-mcp-server 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +52 -2
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -14,6 +14,8 @@ make build
14
14
  --params '{"operation":"get","args":{"key":"sample"}}'
15
15
  ```
16
16
 
17
+ `tools list` and `tools describe` do not connect to Redis. `tools call` and `mcp` connect, then reject an account that can run administrative commands unless `allow_unsafe_database_role` is set. See Service account.
18
+
17
19
  The catalog contains `redis_key`, `redis_string`, `redis_hash`, `redis_list`, `redis_set`, `redis_sorted_set`, `redis_stream`, and `redis_observe`. Write-mode additionally registers the corresponding seven `*_write` tools; there is no raw-command tool and no `redis_observe_write`.
18
20
 
19
21
  Collection responses are bounded to 1–1000 items before reaching Redis. `SCAN`, `HSCAN`, `SSCAN`, and `ZSCAN` return a fixed-length opaque base64url continuation reference, never a Redis-native cursor or buffered value. A continuation remains idle-valid for five minutes after a successful page, with at most 1,000 sessions and 16 MiB of encoded state per adapter; whole sessions are evicted by LRU. Expired or evicted references return `cursor_expired`; a newly unadmittable continuation returns `cursor_unavailable`. Stream entry reads are intentionally absent: the stream catalog is limited to length, bounded pending inspection, and `XCLAIM JUSTID`.
@@ -70,6 +72,7 @@ Both release entry points start MCP over stdio by default. Pass `--port 8080 --l
70
72
  Redis topology is explicit. Password is read only from `MCP_REDIS_PASSWORD`; do not place it in YAML.
71
73
 
72
74
  ```yaml
75
+ allow_unsafe_database_role: false
73
76
  redis:
74
77
  topology: standalone # standalone | cluster | sentinel
75
78
  addresses: ["127.0.0.1:6379"]
@@ -79,8 +82,55 @@ redis:
79
82
  write_enabled: false
80
83
  ```
81
84
 
85
+ `allow_unsafe_database_role` defaults to false. The environment variable is `MCP_ALLOW_UNSAFE_DATABASE_ROLE`. Password remains `MCP_REDIS_PASSWORD` only.
86
+
82
87
  Use `sentinel_master` for Sentinel. `addresses` lists cluster seeds for Cluster and Sentinel endpoints for Sentinel.
83
88
 
89
+ ### Service account
90
+
91
+ After the process connects, and before any tool runs a Redis command, startup reads the current user's ACL. It sends `PING`, `ACL WHOAMI`, `ACL GETUSER`, and `ACL CAT`. The process exits with `[redis_unsafe_service_role] database service role is not permitted` when any root rule or selector can run:
92
+
93
+ - a command in the `@admin` category, including `CONFIG`, `DEBUG`, `SHUTDOWN`, `ACL SETUSER`, `BGSAVE`, `REPLICAOF`, `MODULE`, `MONITOR`, `CLIENT KILL`, and cluster administration subcommands such as `CLUSTER FAILOVER` and `CLUSTER RESET`
94
+ - `FLUSHALL`, `FLUSHDB`, `SWAPDB`, or `MIGRATE`
95
+ - server-side code and global function or script control: `@scripting`, including `EVAL`, `EVALSHA`, `FCALL`, `SCRIPT DEBUG`, `SCRIPT FLUSH`, `SCRIPT LOAD`, `SCRIPT KILL`, `FUNCTION FLUSH`, `FUNCTION DELETE`, `FUNCTION LOAD`, `FUNCTION RESTORE`, and `FUNCTION KILL`
96
+ - `MEMORY PURGE`
97
+ - every command in that server's `@dangerous` category. Redis 8 adds `TRIMSLOTS` and `BACKUP` there. They are not in `@admin` or `@scripting`, and `@write` and `@keyspace` grant `TRIMSLOTS`
98
+ - `RANDOMKEY` and `SCAN`. Both return key names and do not take a key argument, so a key pattern does not apply to them
99
+ - the whole `ACL`, `CLIENT`, `CLUSTER`, `FUNCTION`, `SCRIPT`, or `MEMORY` command
100
+
101
+ These probe commands are not a rejection by themselves: `ACL WHOAMI`, `ACL GETUSER`, and `ACL CAT`. `ACL GETUSER` cannot be limited to the current username, so this account can also read every user's ACL password hash. That probe disclosure is separate from key names returned by `RANDOMKEY` or `SCAN`. Startup calls `ACL GETUSER` only for the authenticated user and does not log or return that reply. Cluster discovery commands such as `CLUSTER SLOTS`, `CLUSTER NODES`, and `CLUSTER SHARDS` are not a rejection, and neither is `MEMORY USAGE` or `CLIENT SETNAME`. The account must be allowed to run the probe, or startup fails with `[redis_privilege_probe_failed]` even when the opt-out is set. A refused connection fails with `[redis_connection_failed]` and is not skipped by the opt-out.
102
+
103
+ An account limited to the read commands it needs, plus the probe commands, starts with the default configuration. No opt-out is required. `@read` includes `RANDOMKEY` and `SCAN`, so the read account also needs `-randomkey` and `-scan`. On Redis 6.2, `@read` includes `memory`, and `MEMORY PURGE` is not its own ACL name, so that account also needs `-memory`. The same shape works for a business account that grants the data categories and then revokes the global operations. `+@write` includes `FLUSHALL` and, on Redis 7, `FUNCTION FLUSH`, `FUNCTION DELETE`, `FUNCTION LOAD`, and `FUNCTION RESTORE`. On Redis 8 it also includes `TRIMSLOTS`. `+@connection` includes `CLIENT KILL`. `+@slow` and `+@scripting` include `EVAL` and `SCRIPT DEBUG`. Grant the broad category first, then revoke `@admin`, `@dangerous`, and `@scripting`, then revoke `RANDOMKEY`, `SCAN`, and the other individual global commands, then add the probe commands back. Redis 6.2 rejects unknown names such as `-function` and `-memory|purge`. Use `-memory` and `-@scripting` there. `-randomkey` and `-scan` are valid on Redis 6.2.
104
+
105
+ ```redis
106
+ ACL SETUSER mcp-reader on >strong-password ~app:* resetchannels &
107
+ -@all
108
+ +@read
109
+ -@admin
110
+ -@dangerous
111
+ -randomkey
112
+ -scan
113
+ +ping
114
+ +acl|whoami
115
+ +acl|getuser
116
+ +acl|cat
117
+ ```
118
+
119
+ ```redis
120
+ ACL SETUSER mcp-app on >strong-password ~app:* resetchannels &
121
+ -@all
122
+ +@read +@write +@string +@hash +@list +@set +@sortedset +@stream +@fast +@keyspace +@connection
123
+ -@admin -@dangerous -@scripting
124
+ -flushall -flushdb -swapdb -migrate -memory|purge
125
+ -randomkey -scan
126
+ +ping +acl|whoami +acl|getuser +acl|cat
127
+ +cluster|slots +cluster|nodes +cluster|shards
128
+ ```
129
+
130
+ `allow_unsafe_database_role` defaults to `false`. Set it to `true` in the config file, or export `MCP_ALLOW_UNSAFE_DATABASE_ROLE=true`, only when you cannot provision a least-privilege account. The server logs a warning and skips this privilege rejection. A refused connection, a failed ACL probe, and every other startup check still stop startup. The Redis user can still run `FLUSHALL`, `CONFIG`, `DEBUG`, or `SHUTDOWN` outside the tool catalog: this server does not expose a raw command, but the account itself can. Enable the option only for a Redis instance you control.
131
+
132
+ The warning is logged at warn level. HTTP mode shows it at the default `info` log level. Stdio mode keeps logs disabled so MCP output stays intact. Do not use the Redis `default` user. A standard server grants that user `+@all`.
133
+
84
134
  ## Production safety guide
85
135
 
86
136
  This server reduces the Redis capabilities exposed to an AI client; it is not an authentication gateway or a complete data-access policy. Read-only mode prevents mutations, but reads can still disclose data or consume Redis capacity.
@@ -104,7 +154,7 @@ disabled_tools:
104
154
 
105
155
  ### Restrict the Redis account and keyspace
106
156
 
107
- Connect with a dedicated Redis ACL account. Grant it only the commands and key patterns needed by the selected tools; do not use an administrator or application-owner account. A read-only Redis account can still disclose every key it can read, so keep secrets and unrelated tenant data outside its permitted key patterns.
157
+ Connect with a dedicated Redis ACL account. Grant it only the commands and key patterns needed by the selected tools; do not use an administrator or application-owner account. Startup rejects `@admin`, `@dangerous`, `@scripting`, `FLUSHALL`, `FLUSHDB`, `TRIMSLOTS`, `FUNCTION FLUSH`, `SCRIPT DEBUG`, `MEMORY PURGE`, `RANDOMKEY`, `SCAN`, `CONFIG`, `DEBUG`, `SHUTDOWN`, and the other commands listed under Service account unless `allow_unsafe_database_role` is set. A key pattern limits commands that name a key. It does not apply to keyless commands. `RANDOMKEY` and `SCAN` return key names from the whole keyspace, including names the pattern cannot `GET`. `DBSIZE` still counts those keys. `redis_key` `random_key` and `redis_observe` `scan` call `RANDOMKEY` and `SCAN`, so a tenant profile that revokes those commands cannot use those operations. `ACL GETUSER` remains a separate probe permission and is not a key-name listing.
108
158
 
109
159
  ### Put HTTP and SSE behind an authenticated boundary
110
160
 
@@ -112,7 +162,7 @@ Prefer stdio for local MCP clients. When using HTTP or SSE, place the server beh
112
162
 
113
163
  ### Bound enumeration and verify the deployed catalog
114
164
 
115
- `SCAN`-based operations avoid the blocking `KEYS` command and each collection page is bounded, but repeated requests can still enumerate a large keyspace. Apply gateway quotas and monitoring for request rate, scan volume, latency, and errors. Before deployment, inspect the actual catalog:
165
+ `SCAN` does not take a key, so a key pattern does not limit it. A tenant profile revokes `SCAN` and `RANDOMKEY`. Where those commands remain granted, repeated `SCAN` requests can list key names outside that pattern. Each collection page is still bounded. Apply gateway quotas and monitoring for request rate, scan volume, latency, and errors. Before deployment, inspect the actual catalog:
116
166
 
117
167
  ```bash
118
168
  ./bin/redis-mcp-server tools list --config production.yaml
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@futuretea/redis-mcp-server",
3
- "version": "0.0.3",
3
+ "version": "0.1.0",
4
4
  "description": "Redis Model Context Protocol server",
5
5
  "main": "./bin/index.js",
6
6
  "bin": {
7
7
  "redis-mcp-server": "bin/index.js"
8
8
  },
9
9
  "optionalDependencies": {
10
- "@futuretea/redis-mcp-server-darwin-amd64": "0.0.3",
11
- "@futuretea/redis-mcp-server-darwin-arm64": "0.0.3",
12
- "@futuretea/redis-mcp-server-linux-amd64": "0.0.3",
13
- "@futuretea/redis-mcp-server-linux-arm64": "0.0.3",
14
- "@futuretea/redis-mcp-server-windows-amd64": "0.0.3"
10
+ "@futuretea/redis-mcp-server-darwin-amd64": "0.1.0",
11
+ "@futuretea/redis-mcp-server-darwin-arm64": "0.1.0",
12
+ "@futuretea/redis-mcp-server-linux-amd64": "0.1.0",
13
+ "@futuretea/redis-mcp-server-linux-arm64": "0.1.0",
14
+ "@futuretea/redis-mcp-server-windows-amd64": "0.1.0"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",