Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

scan_keys

Scan keys in Redis using the SCAN command for non-blocking, production-safe iteration. Use a pattern to match keys and a cursor to paginate through results for complete retrieval.

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

TableJSON Schema
NameRequiredDescriptionDefault
patternNo*
countNo
cursorNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations, so description must cover behavior. Explains non-blocking, production-safe, partial results, count as hint, cursor iteration. No mention of limitations like memory, but sufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well-structured with sections and warning. Some verbosity in example, but earns its place. Front-loaded with key info.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers all aspects: purpose, parameters, output format (split into fields), and iteration workflow. No gaps given output schema and complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has no property descriptions (0% coverage). Description adds meaningful details: pattern examples, count as hint, cursor usage. Fully compensates for schema gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states 'Scan keys in the Redis database using the SCAN command' and distinguishes from sibling 'scan_all_keys' by noting partial results. Verb and resource specific.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly recommends using scan_all_keys for full results and shows iteration pattern. Does not mention non-usage scenarios but provides clear context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

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