Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

xrange

Retrieve entries from a Redis stream by specifying a key and optional count to access stored data sequences.

Instructions

Read entries from a Redis stream.

Args: key (str): The stream key. count (int, optional): Number of entries to retrieve.

Returns: str: The retrieved stream entries or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYes
countNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The 'xrange' tool handler: an async function decorated with @mcp.tool() that reads up to 'count' entries from the Redis stream 'key' and returns them as a string or an error message.
    @mcp.tool()
    async def xrange(key: str, count: int = 1) -> str:
        """Read entries from a Redis stream.
    
        Args:
            key (str): The stream key.
            count (int, optional): Number of entries to retrieve.
    
        Returns:
            str: The retrieved stream entries or an error message.
        """
        try:
            r = RedisConnectionManager.get_connection()
            entries = r.xrange(key, count=count)
            return str(entries) if entries else f"Stream {key} is empty or does not exist"
        except RedisError as e:
            return f"Error reading from stream {key}: {str(e)}"
Behavior2/5

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

With no annotations provided, the description carries full burden but lacks behavioral details. It mentions reading entries but doesn't disclose aspects like ordering (e.g., chronological retrieval), error conditions beyond a generic 'error message', or performance implications (e.g., rate limits). This leaves gaps in understanding the tool's behavior.

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?

The description is well-structured and appropriately sized, with a clear opening sentence followed by parameter and return sections. Every sentence adds value, though the 'Returns' section could be more concise by leveraging the output schema.

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

Completeness3/5

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

Given the tool's moderate complexity (2 parameters, no annotations, but with an output schema), the description is somewhat complete but has gaps. It covers the basic purpose and parameters but lacks usage guidelines and detailed behavioral context, making it adequate but not fully informative for an agent.

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

Parameters3/5

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

The description adds minimal semantics beyond the input schema, which has 0% coverage. It explains 'key' as 'The stream key' and 'count' as 'Number of entries to retrieve', but doesn't clarify format (e.g., Redis key patterns) or constraints (e.g., count limits). With low schema coverage, this partially compensates but remains basic.

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?

The description clearly states the specific action ('Read entries') and resource ('from a Redis stream'), distinguishing it from sibling tools like 'xadd' (add to stream) and 'xdel' (delete from stream). It precisely defines the tool's function without ambiguity.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'xadd' for adding entries or 'lrange' for list operations, nor does it specify prerequisites or contexts for usage, leaving the agent without selection criteria.

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