@futuretea/redis-mcp-server 0.0.1
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.
- package/LICENSE +21 -0
- package/README.md +141 -0
- package/bin/index.js +46 -0
- package/package.json +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 futuretea
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Redis MCP Server
|
|
2
|
+
|
|
3
|
+
[中文文档](README.zh.md)
|
|
4
|
+
|
|
5
|
+
Redis MCP Server exposes a closed, semantic Redis data-plane catalog over MCP and the bundled CLI. It supports explicit standalone, Cluster, and Sentinel configurations. Tools are read-only by default; write tools are registered only when `redis.write_enabled=true`.
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
make build
|
|
11
|
+
./bin/redis-mcp-server tools list --config config.example.yaml
|
|
12
|
+
./bin/redis-mcp-server tools describe redis_string --config config.example.yaml
|
|
13
|
+
./bin/redis-mcp-server tools call redis_string --config config.example.yaml \
|
|
14
|
+
--params '{"operation":"get","args":{"key":"sample"}}'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
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
|
+
|
|
19
|
+
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`.
|
|
20
|
+
|
|
21
|
+
## Use a release
|
|
22
|
+
|
|
23
|
+
Stable releases use tags in the form `vX.Y.Z`. npm uses `X.Y.Z`; Docker uses `vX.Y.Z`. npm packages support macOS (Intel and Apple Silicon), Linux (x64 and ARM64), and Windows x64. Docker images support Linux `amd64` and `arm64`.
|
|
24
|
+
|
|
25
|
+
### npm
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
export MCP_REDIS_PASSWORD='your-redis-password'
|
|
29
|
+
npx -y @futuretea/redis-mcp-server@X.Y.Z --config /path/to/redis-mcp.yaml
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Configure an MCP client that supports stdio with the same version and configuration path:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"mcpServers": {
|
|
37
|
+
"redis": {
|
|
38
|
+
"command": "npx",
|
|
39
|
+
"args": [
|
|
40
|
+
"-y",
|
|
41
|
+
"@futuretea/redis-mcp-server@X.Y.Z",
|
|
42
|
+
"--config",
|
|
43
|
+
"/absolute/path/to/redis-mcp.yaml"
|
|
44
|
+
],
|
|
45
|
+
"env": {
|
|
46
|
+
"MCP_REDIS_PASSWORD": "your-redis-password"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Docker
|
|
54
|
+
|
|
55
|
+
Mount the Redis configuration file read-only and keep the password in the runtime environment:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
export MCP_REDIS_PASSWORD='your-redis-password'
|
|
59
|
+
docker run --rm -i \
|
|
60
|
+
--env MCP_REDIS_PASSWORD \
|
|
61
|
+
--mount type=bind,src="$PWD/redis-mcp.yaml",dst=/etc/redis-mcp-server/config.yaml,readonly \
|
|
62
|
+
ghcr.io/futuretea/redis-mcp-server:vX.Y.Z \
|
|
63
|
+
--config /etc/redis-mcp-server/config.yaml
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Both release entry points start MCP over stdio by default. Pass `--port 8080 --listen 0.0.0.0` after the release command to start HTTP in a container, and publish the port only to the network that should reach it.
|
|
67
|
+
|
|
68
|
+
## Configuration
|
|
69
|
+
|
|
70
|
+
Redis topology is explicit. Password is read only from `MCP_REDIS_PASSWORD`; do not place it in YAML.
|
|
71
|
+
|
|
72
|
+
```yaml
|
|
73
|
+
redis:
|
|
74
|
+
topology: standalone # standalone | cluster | sentinel
|
|
75
|
+
addresses: ["127.0.0.1:6379"]
|
|
76
|
+
username: ""
|
|
77
|
+
tls: false
|
|
78
|
+
sentinel_master: ""
|
|
79
|
+
write_enabled: false
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Use `sentinel_master` for Sentinel. `addresses` lists cluster seeds for Cluster and Sentinel endpoints for Sentinel.
|
|
83
|
+
|
|
84
|
+
## Production safety guide
|
|
85
|
+
|
|
86
|
+
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.
|
|
87
|
+
|
|
88
|
+
### Keep writes disabled by default
|
|
89
|
+
|
|
90
|
+
Keep `redis.write_enabled: false` for untrusted or general-purpose AI clients. Enabling it registers mutation tools, including key deletion and collection trimming; it is not a per-request approval mode.
|
|
91
|
+
|
|
92
|
+
### Expose the smallest useful tool set
|
|
93
|
+
|
|
94
|
+
Use `enabled_tools` to expose only the tool families required by the client. Tool filtering is at the tool level, not the operation level: enabling `redis_string`, for example, exposes all of that tool's declared read operations. Do not expose `redis_key` or `redis_observe` to an untrusted client unless key discovery and keyspace metadata are required.
|
|
95
|
+
|
|
96
|
+
```yaml
|
|
97
|
+
enabled_tools:
|
|
98
|
+
- redis_string
|
|
99
|
+
- redis_hash
|
|
100
|
+
disabled_tools:
|
|
101
|
+
- redis_key
|
|
102
|
+
- redis_observe
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Restrict the Redis account and keyspace
|
|
106
|
+
|
|
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.
|
|
108
|
+
|
|
109
|
+
### Put HTTP and SSE behind an authenticated boundary
|
|
110
|
+
|
|
111
|
+
Prefer stdio for local MCP clients. When using HTTP or SSE, place the server behind TLS, fail-closed authentication, network isolation, and request rate/concurrency limits. Do not expose the process directly to an untrusted network.
|
|
112
|
+
|
|
113
|
+
### Bound enumeration and verify the deployed catalog
|
|
114
|
+
|
|
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:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
./bin/redis-mcp-server tools list --config production.yaml
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Confirm that no `*_write` tool is registered and that every listed tool is intentional. Also verify that the deployment boundary rejects unauthenticated requests and that the Redis ACL denies keys outside the intended scope.
|
|
122
|
+
|
|
123
|
+
## Transports and deployment
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
./bin/redis-mcp-server mcp --config config.example.yaml
|
|
127
|
+
./bin/redis-mcp-server mcp --config config.example.yaml --port 8080
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Streamable HTTP and SSE remain available. If HTTP/SSE is publicly exposed, an external fail-closed authentication boundary must reject unauthenticated requests before they reach this process. This repository does not implement authentication, gateway integration, or authentication-header authorization.
|
|
131
|
+
|
|
132
|
+
## Development
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
make test
|
|
136
|
+
make lint
|
|
137
|
+
make build
|
|
138
|
+
make integration
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`make integration` uses the pinned Redis 8.8.1 image in `testdata/redis/images.lock` to start standalone, Cluster, and Sentinel test topologies. Docker, image, network, compose, or integration-test failures make the target fail.
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const childProcess = require('child_process');
|
|
4
|
+
|
|
5
|
+
const BINARY_MAP = {
|
|
6
|
+
darwin_x64: {name: 'redis-mcp-server-darwin-amd64', suffix: ''},
|
|
7
|
+
darwin_arm64: {name: 'redis-mcp-server-darwin-arm64', suffix: ''},
|
|
8
|
+
linux_x64: {name: 'redis-mcp-server-linux-amd64', suffix: ''},
|
|
9
|
+
linux_arm64: {name: 'redis-mcp-server-linux-arm64', suffix: ''},
|
|
10
|
+
win32_x64: {name: 'redis-mcp-server-windows-amd64', suffix: '.exe'},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const resolveBinaryPath = () => {
|
|
14
|
+
const binary = BINARY_MAP[`${process.platform}_${process.arch}`];
|
|
15
|
+
if (!binary) {
|
|
16
|
+
throw new Error(`Unsupported platform/architecture: ${process.platform}/${process.arch}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
return require.resolve(`@futuretea/${binary.name}/bin/redis-mcp-server${binary.suffix}`);
|
|
21
|
+
} catch {
|
|
22
|
+
throw new Error(`Could not resolve binary path for platform/architecture: ${process.platform}/${process.arch}`);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const child = childProcess.spawn(resolveBinaryPath(), ['mcp', ...process.argv.slice(2)], {
|
|
27
|
+
stdio: 'inherit',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const handleSignal = (signal) => {
|
|
31
|
+
if (!child.killed) {
|
|
32
|
+
child.kill(signal);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
['SIGTERM', 'SIGINT', 'SIGHUP'].forEach((signal) => {
|
|
37
|
+
process.on(signal, () => handleSignal(signal));
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
child.on('close', (code, signal) => {
|
|
41
|
+
if (signal) {
|
|
42
|
+
process.exit(128 + (signal === 'SIGTERM' ? 15 : signal === 'SIGINT' ? 2 : 1));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
process.exit(code || 0);
|
|
46
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@futuretea/redis-mcp-server",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Redis Model Context Protocol server",
|
|
5
|
+
"main": "./bin/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"redis-mcp-server": "bin/index.js"
|
|
8
|
+
},
|
|
9
|
+
"optionalDependencies": {
|
|
10
|
+
"@futuretea/redis-mcp-server-darwin-amd64": "0.0.1",
|
|
11
|
+
"@futuretea/redis-mcp-server-darwin-arm64": "0.0.1",
|
|
12
|
+
"@futuretea/redis-mcp-server-linux-amd64": "0.0.1",
|
|
13
|
+
"@futuretea/redis-mcp-server-linux-arm64": "0.0.1",
|
|
14
|
+
"@futuretea/redis-mcp-server-windows-amd64": "0.0.1"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/futuretea/redis-mcp-server.git"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"mcp",
|
|
22
|
+
"redis",
|
|
23
|
+
"database",
|
|
24
|
+
"model-context-protocol"
|
|
25
|
+
],
|
|
26
|
+
"author": {
|
|
27
|
+
"name": "futuretea",
|
|
28
|
+
"url": "https://github.com/futuretea"
|
|
29
|
+
},
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/futuretea/redis-mcp-server/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/futuretea/redis-mcp-server#readme"
|
|
35
|
+
}
|