MCP Redis Server
An MCP Redis server with data operations, permission control, and operation logging.
Features
- ✅ Redis data operations (GET, SET, UPDATE, DELETE)
- ✅ Key management (CREATE, DROP, EXISTS, INFO)
- ✅ Permission-based dynamic tool list
- ✅ Operation logging
- ✅ Connection management
- ✅ Auto reconnection mechanism
- ✅ Health check
- ✅ Error handling and recovery
Installation
Global Install (Recommended)
npm install -g @liangshanli/mcp-server-redis
Local Install
npm install @liangshanli/mcp-server-redis
From Source
git clone https://github.com/liliangshan/mcp-server-redis.git
cd mcp-server-redis
npm install
Configuration
Set environment variables:
export HOST=localhost
export PORT=6379
export PASSWORD=your_password
export ALLOW_INSERT=true
export ALLOW_UPDATE=true
export ALLOW_DELETE=true
export ALLOW_CREATE=true
export ALLOW_DROP=true
Environment Variables
| Variable | Default | Description |
|---|---|---|
HOST |
localhost | Redis host address |
PORT |
6379 | Redis port |
PASSWORD |
- | Redis password |
ALLOW_INSERT |
true | Allow insert operations |
ALLOW_UPDATE |
true | Allow update operations |
ALLOW_DELETE |
true | Allow delete operations |
ALLOW_CREATE |
true | Allow key creation operations |
ALLOW_DROP |
true | Allow key deletion operations |
MCP_LOG_DIR |
./logs | Log directory |
Usage
1. Direct Run (Global Install)
mcp-server-redis
2. Using npx (Recommended)
npx @liangshanli/mcp-server-redis
3. Direct Start (Source Install)
npm start
4. Managed Start (Production Recommended)
npm run start-managed
Managed start provides: auto-restart (max 10 times), error recovery, process management, logging
5. Dev Mode
npm run dev
Editor Integration
Cursor Editor Configuration
Create `.cursor/mcp.json` file in project root:
{
"mcpServers": {
"redis": {
"command": "npx",
"args": ["@liangshanli/mcp-server-redis"],
"env": {
"HOST": "your_host",
"PORT": "6379",
"PASSWORD": "your_password",
"ALLOW_INSERT": "true",
"ALLOW_UPDATE": "true",
"ALLOW_DELETE": "true",
"ALLOW_CREATE": "true",
"ALLOW_DROP": "true"
}
}
}
}
VS Code Editor Configuration
Create `.vscode/mcp.json` file:
{
"servers": {
"redis": {
"command": "npx",
"args": ["@liangshanli/mcp-server-redis"],
"env": {
"HOST": "your_host",
"PORT": "6379",
"PASSWORD": "your_password",
"ALLOW_INSERT": "true",
"ALLOW_UPDATE": "true",
"ALLOW_DELETE": "true",
"ALLOW_CREATE": "true",
"ALLOW_DROP": "true"
}
}
}
}
Permission Control Examples
Default: Enable All Operations
export ALLOW_INSERT=true
export ALLOW_UPDATE=true
export ALLOW_DELETE=true
export ALLOW_CREATE=true
export ALLOW_DROP=true
Read-Only: Disable Write Operations
export ALLOW_INSERT=false
export ALLOW_UPDATE=false
export ALLOW_DELETE=false
export ALLOW_CREATE=false
export ALLOW_DROP=false
Custom: Enable Specific Operations
export ALLOW_INSERT=true
export ALLOW_UPDATE=true
export ALLOW_DELETE=false
export ALLOW_CREATE=false
export ALLOW_DROP=false
MCP Tools
1. redis_set
Set key-value in Redis.
{
"name": "redis_set",
"arguments": {
"key": "user:1001",
"value": "John Doe"
}
}
2. redis_get
Get value by key from Redis.
{
"name": "redis_get",
"arguments": {
"key": "user:1001"
}
}
3. redis_delete
Delete key from Redis.
{
"name": "redis_delete",
"arguments": {
"key": "user:1001"
}
}
4. redis_exists
Check if key exists in Redis.
{
"name": "redis_exists",
"arguments": {
"key": "user:1001"
}
}
5. redis_keys
Get all keys matching pattern.
{
"name": "redis_keys",
"arguments": {
"pattern": "user:*"
}
}
6. redis_info
Get Redis server information.