Redis CLI
73.5k stars
official open-source Has MCP macOS Linux Actively maintained
The official CLI for Redis. Query keys, manage data structures, monitor server health, and execute Lua scripts across any Redis instance.
Redis CLI has both a CLI and an MCP server. See when to use each
Part of the Redis CLI tools for AI agents
What your agent can do
Your application is slow. You suspect the cache. You open a Redis GUI, click through databases, search for keys, check TTLs one at a time. By the time you find the problem, your users found it first. Your agent runs `redis-cli --scan --pattern "session:*" | head -20` and `redis-cli INFO memory` in seconds. Problem located, fix deployed.Redis stores more than strings. It handles JSON documents, sorted sets for leaderboards, streams for event logs, pub/sub for real-time messaging. Your agent works with all of them through the same CLI. `redis-cli JSON.GET config:app $.features` reads a nested JSON document. `redis-cli XRANGE events:orders - + COUNT 10` reads the last 10 order events from a stream. One tool, every Redis data structure.The `--raw` flag is what separates scripting from interactive use. Without it, redis-cli wraps strings in quotes and adds type prefixes. With `--raw`, output is clean text your agent pipes directly into `jq`, `wc`, or another command. `redis-cli --raw KEYS "cache:*" | wc -l` counts cached keys instantly.For bulk operations, `--pipe` mode sends commands at wire speed. Your agent generates a protocol file and pipes it in: `cat commands.txt | redis-cli --pipe`. Thousands of writes per second without the overhead of individual command round-trips. The official Redis docs call this "mass insertion" and it's the fastest way to seed data.The insider detail: `SCAN` vs `KEYS`. Both find keys by pattern, but `KEYS` blocks the server while it searches. On a production instance with millions of keys, `KEYS *` can freeze everything for seconds. `SCAN` paginates the search across multiple calls, never blocking. Your agent always uses `SCAN`. Humans often reach for `KEYS` first.
Limitations
No native `--json` output flag for arbitrary commands. Output is plain text or RESP protocol, which agents parse line-by-line. The `--csv` flag works for some commands but not all. Redis-specific with no support for other databases. Server management (clustering, failover configuration) requires separate tools like `redis-sentinel` and the Redis admin commands.
Key Commands
redis-cli GET Retrieve the value of a key
redis-cli SET Set a key to a string value with optional expiration
redis-cli INFO Return server statistics including memory, CPU, replication, and keyspace
redis-cli SCAN Incrementally iterate through keys matching a pattern without blocking
redis-cli JSON.GET Retrieve a JSON document stored in a Redis key
redis-cli MONITOR Stream every command processed by the server in real time
redis-cli --eval Execute a Lua script against the server
GitHub Stats
repo redis/redis
stars 73.5k
language C
license RSALv2/SSPLv1
last commit Mar 24, 2026
FAQ
- Is Redis CLI free?
- Yes. redis-cli ships with Redis under RSALv2/SSPLv1 dual license. The CLI is free for all uses including commercial. On Debian/Ubuntu, install just the client tools with `sudo apt-get install redis-tools` — no server required. On macOS, `brew install redis` includes the CLI. For managed Redis services (AWS ElastiCache, Upstash, Redis Cloud), you connect redis-cli to the remote endpoint.
- Can AI agents use Redis CLI?
- Yes. redis-cli runs fully non-interactive. Your agent executes single commands (`redis-cli GET key`), pipes bulk operations (`cat commands.txt | redis-cli --pipe`), and runs Lua scripts (`redis-cli --eval script.lua`). The `--raw` flag outputs clean text for piping into other tools. Redis also has an official MCP server (redis/mcp-redis) that gives agents natural-language access to Redis operations.
- How do you connect Redis CLI to a remote server?
- Use `redis-cli -h hostname -p port -a password`. For TLS connections (required by most managed services), add `--tls`. Example: `redis-cli -h redis.example.com -p 6380 --tls -a yourpassword`. For connection strings, use `redis-cli -u redis://user:pass@host:port`. Your agent stores credentials in environment variables and connects automatically.
- What is the difference between KEYS and SCAN in Redis?
- KEYS blocks the server while searching. On a database with millions of keys, `KEYS *` can freeze Redis for seconds, causing timeouts across your application. SCAN paginates the search across cursor-based iterations, never blocking. Your agent always uses `redis-cli --scan --pattern 'prefix:*'` instead of KEYS. This is the single most important Redis CLI habit.
- Does Redis CLI support JSON?
- Redis has native JSON support via the RedisJSON module. Your agent uses `redis-cli JSON.GET key $.path` to query JSON documents and `redis-cli JSON.SET key $.path 'value'` to update them. The commands support JSONPath syntax for nested access. However, the CLI itself doesn't have a `--json` output format flag — general command output is plain text, not JSON.
Related tools in Databases
psql official
brew install libpq && brew link --force libpq
category Databases
The official PostgreSQL CLI. Run queries, inspect schemas, export data, and manage databases with JSON, CSV, and HTML output formats.
20.4k
Supabase CLI official
brew install supabase/tap/supabase
category Databases
The official CLI for Supabase. Run Supabase locally, manage database migrations, deploy edge functions, and generate TypeScript types from your schema.
1.6k
mongosh official
brew install mongosh
category Databases
The official MongoDB Shell. Query documents, run aggregation pipelines, manage collections, and script database operations with native JSON output.
383
Last verified: Mar 25, 2026