communitystdio

Redis MCP Server

Get, set, and scan Redis keys with TTL control from Claude Code or Cursor over a safe command subset.

Updated: April 15, 2026

Install

npx mcp-server-redis
~/.claude/settings.json
{
  "mcpServers": {
    "redis-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-server-redis"
      ],
      "env": {
        "REDIS_URL": "redis://localhost:6379"
      }
    }
  }
}

Capabilities

  • + Get, set, and delete string keys with optional TTL in seconds or milliseconds
  • + Manage expiration through EXPIRE, PERSIST, and TTL inspection
  • + Read and write hash fields with HGET, HSET, HGETALL, and HDEL
  • + Work with list and set data structures through LPUSH, LRANGE, SADD, and SMEMBERS
  • + Scan keys by pattern with cursor-based SCAN to avoid blocking the server
  • + Check key existence and type before the agent mutates anything

Limitations

  • - No pub/sub or keyspace notification support - the server is request-response only
  • - Command surface is a safe subset; FLUSHALL, CONFIG, and DEBUG are blocked
  • - No Redis Cluster mode routing; the server assumes a single node or sentinel-backed writer
  • - No Lua scripting through EVAL or EVALSHA for safety reasons

Redis MCP server setup for Claude Code and Cursor

Quick answer: The Redis MCP server is a Node process that wraps a safe subset of Redis commands as MCP tools. Install with one npx command, set REDIS_URL in the env block, and Claude Code or Cursor can read, write, and scan keys. Setup takes 3 minutes, tested on server version 0.5.2 against Redis 7.2 on April 15, 2026.

The Redis MCP server wires a coding agent into your cache or key-value store. Instead of telling Claude what keys exist, it runs SCAN and sees them. Instead of guessing at a TTL, it checks one. The loop is short and the tools map one-to-one with Redis commands you already know.

This guide covers installation, config for both editors, realistic prompts, and the commands the server intentionally does not expose.

What this server does

The server exposes about 25 Redis commands as MCP tools over a single connection. When Claude wants to read a value, it calls get with a key. When it wants to scan for keys, it calls scan with a pattern and a cursor. The server uses the official ioredis client under the hood and maps tool calls directly to Redis RESP commands.

Supported command families:

  • Strings: get, set, del, mget, mset, incr, decr
  • TTL: expire, persist, ttl, pexpire, pttl
  • Hashes: hget, hset, hgetall, hdel, hkeys
  • Lists: lpush, rpush, lrange, llen, lpop, rpop
  • Sets: sadd, smembers, srem, sismember, scard
  • Scan: scan, hscan, sscan
  • Meta: exists, type, keys (with a limit cap)

Blocked commands include FLUSHALL, FLUSHDB, CONFIG, DEBUG, EVAL, EVALSHA, BGSAVE, and SHUTDOWN. These would either destroy data, change runtime behavior, or execute arbitrary Lua - not safe for an agent loop.

Installing Redis MCP

The package is published as mcp-server-redis. The npx -y prefix fetches on first launch and caches. Cold start is about 2 seconds and pulls roughly 2.5 MB including the ioredis dependency.

You need a Redis instance the server can reach. Local options:

  1. brew install redis and brew services start redis on macOS.
  2. docker run -d -p 6379:6379 redis:7.2 on any machine with Docker.
  3. Your existing Upstash, Redis Cloud, or self-hosted instance - just copy the connection string.

The REDIS_URL env var follows the standard scheme: redis://[user:password@]host:port[/db]. For TLS-enabled hosts like Upstash, use rediss:// with the double s.

Configuring for Claude Code

Claude Code reads MCP servers from ~/.claude/mcp.json globally or .mcp.json at the project root. Add a redis entry with the URL in env:

{
  "mcpServers": {
    "redis": {
      "command": "npx",
      "args": ["-y", "mcp-server-redis"],
      "env": {
        "REDIS_URL": "redis://localhost:6379"
      }
    }
  }
}

Restart Claude Code. Run /mcp and confirm the server is attached with around 25 tool names. Call exists on a throwaway key as a smoke test - if it returns 0, the connection works.

For a production Redis, use a read replica endpoint and a user with a narrow ACL. The server does not know about Redis ACLs directly - it just sees the permission errors and surfaces them to the model.

Configuring for Cursor

Cursor uses the same MCP spec with the same JSON shape. The file lives at ~/.cursor/mcp.json:

{
  "mcpServers": {
    "redis": {
      "command": "npx",
      "args": ["-y", "mcp-server-redis"],
      "env": {
        "REDIS_URL": "redis://localhost:6379"
      }
    }
  }
}

Open Cursor settings > MCP and toggle the server on. First tool call takes about 2 seconds for spawn plus connection handshake. Subsequent calls are sub-10 ms on localhost or 20 to 60 ms to a regional cloud endpoint.

Example prompts and workflows

Once the server is attached, Redis acts like a scratchpad the agent can read and write. A few prompts:

  • "Scan all keys matching session:* and tell me which ones expire in the next hour."
  • "Read the hash at user:42 and show me every field."
  • "Set the key feature:new-checkout to enabled with a 24 hour TTL."
  • "Show me the 10 most recent entries in the list events:global."
  • "Delete every key matching cache:stale:* one batch at a time."

The model chains calls on its own. A "show me expiring sessions" prompt runs scan with a cursor, then ttl on each returned key. That is 1 scan call plus N TTL calls - for 100 sessions, roughly 1.2 seconds on localhost and 6 seconds on a remote endpoint.

One pattern worth knowing: ask the model to use scan rather than keys on anything production-adjacent. The keys command blocks the Redis event loop and can freeze a busy instance. The server caps keys results at 1000 to reduce the blast radius, but scan is still the correct choice.

Troubleshooting

Tool call fails with ECONNREFUSED. Redis is not running or not listening on the host and port in REDIS_URL. Check with redis-cli ping from the same machine where the MCP server runs.

Tool call returns NOAUTH. The connection string is missing a password. Use the full form redis://:yourpassword@host:6379. Upstash and Redis Cloud both require this.

TLS handshake fails. The host expects TLS but the URL uses redis://. Change the scheme to rediss:// with the double s.

Command not allowed error. The command is in the blocklist. If you genuinely need FLUSHDB during development, run it via redis-cli directly; the server will not proxy it regardless of ACL.

Server fails to start with ENOENT. npx is not on PATH in the editor's env. Launch from a terminal or set the absolute path to npx in the config.

Alternatives

If the Redis server does not fit, a few options exist:

  • mcp-server-valkey targets the Valkey fork of Redis with the same command surface.
  • memcached-mcp for teams on Memcached instead of Redis.
  • Direct redis-cli integration through a shell MCP like bash-mcp if you need the full command set including FLUSHALL for scratch databases.

For heavy analytical workloads, connecting the agent to a read-only replica of Redis is faster than hitting the write node directly - latency drops about 30% and you avoid any risk of accidental writes on the hot instance.

The Redis MCP server is the right default for agents that need cache or session visibility. Three minutes of setup replaces a lot of redis-cli round trips. Keep it pointed at a non-production instance while you learn the prompt patterns, then promote it once you trust the agent's judgement.

Guides

Frequently asked questions

Does the server support Redis Cluster mode?

Not reliably. The `ioredis` client can route commands in cluster mode, but the MCP server assumes a single endpoint. For cluster deployments, point the server at a single shard and run one MCP server per shard, or use a Redis Proxy in front.

Can I use this with Upstash or Redis Cloud?

Yes. Use the `rediss://` TLS scheme and paste the full connection string from the Upstash console into `REDIS_URL`. The server handles TLS automatically.

How do I stop the agent from running KEYS on a huge database?

The server caps `KEYS` results at 1000 and emits a warning when the pattern matches more. In your prompt, tell the model to use `SCAN` instead. Most models take the hint after one correction.

Does it support streams (XADD, XREAD)?

Partially. The server exposes `xadd`, `xrange`, and `xlen` for basic stream reads and writes. Consumer groups and blocking reads are not exposed because the stdio transport cannot support long-lived blocking calls.

Can the agent pipeline multiple commands for performance?

The server batches commands server-side but each MCP tool call is a round trip. For bulk operations, tell the model to use `mset` and `mget` instead of many individual `set` and `get` calls.

What happens if Redis goes down while the MCP server is running?

The `ioredis` client reconnects automatically with exponential backoff. Tool calls during the outage return a connection error; once Redis comes back, subsequent calls succeed without a server restart.