/ Каталог / Песочница / Redis
● Официальный redis 🔑 Нужен свой ключ

Redis

автор redis · redis/mcp-redis

Talk to Redis in English — inspect keys, manage caches, tune expirations, and debug pub/sub without memorizing every Redis command.

Redis's official MCP exposes the full Redis command surface through typed tools: strings, hashes, lists, sets, sorted sets, streams, pub/sub, and key management. Defaults to a single Redis URL; works with OSS Redis, Redis Stack, Redis Cloud, and ElastiCache/MemoryDB.

Зачем использовать

Ключевые функции

Живое демо

Как выглядит на практике

redis.replay ▶ готово
0/0

Установка

Выберите клиент

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "redis": {
      "command": "uvx",
      "args": [
        "mcp-redis"
      ]
    }
  }
}

Откройте Claude Desktop → Settings → Developer → Edit Config. Перезапустите после сохранения.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "redis": {
      "command": "uvx",
      "args": [
        "mcp-redis"
      ]
    }
  }
}

Cursor использует ту же схему mcpServers, что и Claude Desktop. Конфиг проекта приоритетнее глобального.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "redis": {
      "command": "uvx",
      "args": [
        "mcp-redis"
      ]
    }
  }
}

Щёлкните значок MCP Servers на боковой панели Cline, затем "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "redis": {
      "command": "uvx",
      "args": [
        "mcp-redis"
      ]
    }
  }
}

Тот же формат, что и Claude Desktop. Перезапустите Windsurf для применения.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "redis",
      "command": "uvx",
      "args": [
        "mcp-redis"
      ]
    }
  ]
}

Continue использует массив объектов серверов, а не map.

~/.config/zed/settings.json
{
  "context_servers": {
    "redis": {
      "command": {
        "path": "uvx",
        "args": [
          "mcp-redis"
        ]
      }
    }
  }
}

Добавьте в context_servers. Zed перезагружается автоматически.

claude mcp add redis -- uvx mcp-redis

Однострочная команда. Проверить: claude mcp list. Удалить: claude mcp remove.

Сценарии использования

Реальные сценарии: Redis

Investigate why a cached value is stale or missing

👤 Backend engineers debugging cache bugs ⏱ ~10 min beginner

Когда использовать: A user says 'I updated my profile but it's still showing the old name' — likely a cache invalidation issue.

Предварительные требования
  • Redis URL with at least read accessREDIS_URL=redis://:pw@host:6379/0
Поток
  1. Find the right key
    Scan keys matching user:profile:42* — show each with its type and TTL.✓ Скопировано
    → Matching keys list
  2. Inspect the stored value and expiry
    For user:profile:42, GET the value and show the TTL. Is it stale vs expected?✓ Скопировано
    → Value + TTL + verdict
  3. Bust it deliberately
    Delete that key (and any related list/set keys) so the app repopulates on next read. Confirm deletion.✓ Скопировано
    → DEL returned 1 or more

Итог: A confirmed-fixed cache with a trail of what was stale and why.

Подводные камни
  • KEYS * on a big instance stalls the server — Always use SCAN (the server translates scan tools to non-blocking cursors); never KEYS

Audit rate-limit counters for abuse patterns

👤 Platform / abuse team ⏱ ~15 min intermediate

Когда использовать: You suspect a client is bursting against your rate limiter; you want to see live counters and TTLs.

Поток
  1. List active counters
    Scan for keys matching ratelimit:* and group by prefix. Show count per group.✓ Скопировано
    → Prefix histogram
  2. Find top consumers
    For ratelimit:api:*, return the 20 keys with the highest integer value.✓ Скопировано
    → Top-20 offenders
  3. Block or reset
    For abusive key ratelimit:api:client_abc, DELETE it so the next call fails open — and add client_abc to blocklist set abuse:blocked with EXPIRE 86400.✓ Скопировано
    → Key deleted + blocklist updated

Итог: Live evidence of abuse plus targeted mitigation, all in a few Redis ops.

Подводные камни
  • Deleting a rate-limit key lets the client burst again immediately — Add to a blocklist set first, then delete the counter — not the other way around
Сочетать с: sentry

Find and purge orphan session keys consuming memory

👤 SREs responding to a Redis memory alert ⏱ ~20 min intermediate

Когда использовать: Redis is at 85% maxmemory and you need to know what's filling it before it evicts important keys.

Поток
  1. Sample big keys
    Find the 50 largest keys by memory (use MEMORY USAGE per sampled key across a SCAN pass).✓ Скопировано
    → Largest keys list with sizes
  2. Group by prefix and sum
    From that sample, group keys by the first colon-segment. Sum sizes per group to find the worst prefix.✓ Скопировано
    → Prefix → total bytes
  3. Prune with TTL fix
    For prefix session: keys without TTL (persistent), set EXPIRE to 86400 seconds. Count how many got updated.✓ Скопировано
    → Number of keys given a TTL

Итог: Memory relief plus a root-cause (missing EXPIRE on session writes) to fix in app code.

Подводные камни
  • MEMORY USAGE is expensive on big hashes/zsets — Sample 5–10k keys via SCAN, not the full keyspace
Сочетать с: sentry

Inspect a Redis Stream for stuck consumer-group entries

👤 Engineers using Redis Streams for work queues ⏱ ~20 min advanced

Когда использовать: A consumer group is lagging; messages aren't being ack'd; throughput has tanked.

Поток
  1. Check the stream and groups
    For stream jobs, show XLEN, consumer groups, and pending count per group.✓ Скопировано
    → Backlog numbers
  2. Look at pending entries
    For group workers, list the top 20 PEL entries (XPENDING) — show idle time and consumer.✓ Скопировано
    → Stuck message ids
  3. Reclaim or drop
    XCLAIM idle>300000 the stuck entries to a fresh consumer; or XACK them if they're safe to drop. Confirm with me which before running.✓ Скопировано
    → Reclaim/ack summary

Итог: Stream unblocked with a documented action (claim vs ack) per batch.

Подводные камни
  • XACK without inspecting the message can silently drop work — Always fetch the message body (XRANGE) and confirm it's safe to drop before XACK

Debug feature-flag rollout stored in Redis hashes

👤 Platform teams using Redis-backed flags ⏱ ~10 min beginner

Когда использовать: A flag isn't behaving as expected for a subset of users.

Поток
  1. Inspect the flag hash
    HGETALL flags:new-checkout. Show every field and value.✓ Скопировано
    → Flag definition
  2. Check override set
    SMEMBERS flags:new-checkout:allowlist and flags:new-checkout:blocklist. Is user 42 in either?✓ Скопировано
    → Membership answers
  3. Fix and verify
    SADD user 42 to the allowlist. Re-read HGETALL to confirm flag state is otherwise unchanged.✓ Скопировано
    → Allowlist updated; other fields identical

Итог: The flag matches intended state, with a verified change record.

Подводные камни
  • Writing to flag keys without coordination breaks another admin's ongoing test — Announce in #platform before any write; better, use an admin UI that logs changes
Сочетать с: sentry

Комбинации

Сочетайте с другими MCP — эффект x10

redis + sentry

Correlate a cache key with the Sentry error that referenced it

Sentry event mentions cache key user:profile:42 as missing. GET the key, check its TTL, and confirm whether it was evicted or never populated.✓ Скопировано
redis + postgres

Compare cached counts to source-of-truth in Postgres

GET stats:active_users:today from Redis. Run SELECT COUNT(*) FROM users WHERE last_seen > ... in Postgres. Report drift.✓ Скопировано
redis + filesystem

Export a snapshot of keys for offline analysis

SCAN every key matching session:*, dump key+TTL+size to /tmp/session-audit.jsonl.✓ Скопировано

Инструменты

Что предоставляет этот MCP

ИнструментВходные данныеКогда вызыватьСтоимость
scan pattern: str, count?: int Discover keys by pattern (always, never use KEYS) free
type key: str Before any data-type-specific op on an unknown key free
get / set / del key, value?, ex? String ops — caches, counters, locks free
hgetall / hset / hdel key, field?, value? Structured records stored as hashes free
sadd / smembers / sismember / srem key, member(s) Blocklists, allowlists, memberships free
zadd / zrange / zrangebyscore key, score+member(s) Leaderboards, priority queues free
xadd / xrange / xread / xpending / xclaim / xack stream ops Work queues on Redis Streams free
ttl / expire / persist key, seconds? Check or set expirations free
info / memory_usage section? / key Capacity and perf inspection free

Стоимость и лимиты

Во что обходится

Квота API
Bounded by Redis command-per-second limits (your instance, not the MCP)
Токенов на вызов
Most commands <200 tokens; HGETALL/LRANGE scale with data size
Деньги
Free against your existing Redis. Redis Cloud free tier 30MB.
Совет
Always pass a realistic count to SCAN (default 10 is slow at scale; 1000 is a good batch).

Безопасность

Права, секреты, радиус поражения

Минимальные скоупы: ACL user with `~pattern` and `+@read` for read-only work
Хранение учётных данных: REDIS_URL (includes password) in env; prefer TLS with rediss://
Исходящий трафик: Direct TCP to your Redis endpoint; no third-party proxy
Никогда не давайте: FLUSHALL FLUSHDB CONFIG SET SHUTDOWN

Устранение неполадок

Частые ошибки и исправления

NOAUTH Authentication required

Password missing from REDIS_URL. Use redis://:password@host:6379.

Проверить: redis-cli -u $REDIS_URL PING
MOVED 1234 other-host:6379 (Redis Cluster)

Plain MCP uses standalone client. Point at a cluster-aware proxy or use a non-cluster Redis endpoint.

ERR unknown command 'JSON.GET'

That's Redis Stack only. Either upgrade to Redis Stack / Redis Cloud, or store as hashes.

Проверить: redis-cli MODULE LIST
OOM command not allowed when used memory > 'maxmemory'

Redis is full. Check MEMORY STATS, evict or grow the instance, and set TTLs on future writes.

Проверить: redis-cli INFO memory

Альтернативы

Redis в сравнении

АльтернативаКогда использоватьКомпромисс
Memcached MCPYou have plain KV cache needs, no data structuresMuch smaller surface; no lists/sets/streams
DragonflyDB MCPRedis-compatible but multi-threadedNewer; not every module works

Ещё

Ресурсы

📖 Читать официальный README на GitHub

🐙 Открытые задачи

🔍 Все 400+ MCP-серверов и Skills