Skip to main content
Glama

Redis MCP Server

Official
by redis

scan_keys

Scan Redis database keys safely in chunks using the SCAN command. Ideal for large datasets, it provides partial results per iteration, allowing non-blocking production use. Use a cursor to continue or retrieve all matching keys with scan_all_keys().

Instructions

Scan keys in the Redis database using the SCAN command (non-blocking, production-safe).

⚠️ IMPORTANT: This returns PARTIAL results from one iteration. Use scan_all_keys() to get ALL matching keys, or call this function multiple times with the returned cursor until cursor becomes 0.

The SCAN command iterates through the keyspace in small chunks, making it safe to use on large databases without blocking other operations.

Args: pattern: Pattern to match keys against (default is "" for all keys). Common patterns: "user:", "cache:", ":123", etc. count: Hint for the number of keys to return per iteration (default 100). Redis may return more or fewer keys than this hint. cursor: The cursor position to start scanning from (0 to start from beginning). To continue scanning, use the cursor value returned from previous call.

Returns: A dictionary containing: - 'cursor': Next cursor position (0 means scan is complete) - 'keys': List of keys found in this iteration (PARTIAL RESULTS) - 'total_scanned': Number of keys returned in this batch - 'scan_complete': Boolean indicating if scan is finished Or an error message if something goes wrong.

Example usage: First call: scan_keys("user:") -> returns cursor=1234, keys=[...], scan_complete=False Next call: scan_keys("user:", cursor=1234) -> continues from where it left off Final call: returns cursor=0, scan_complete=True when done

Input Schema

NameRequiredDescriptionDefault
countNo
cursorNo
patternNo*

Input Schema (JSON Schema)

{ "properties": { "count": { "default": 100, "title": "Count", "type": "integer" }, "cursor": { "default": 0, "title": "Cursor", "type": "integer" }, "pattern": { "default": "*", "title": "Pattern", "type": "string" } }, "title": "scan_keysArguments", "type": "object" }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/redis/mcp-redis'

If you have feedback or need assistance with the MCP directory API, please join our Discord server