Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

lrange

Retrieve elements from a Redis list by specifying a start and stop index range. Use this tool to extract specific segments of list data stored in Redis databases.

Instructions

Get elements from a Redis list within a specific range.

Returns: str: A JSON string containing the list of elements or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
startYes
stopYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The 'lrange' tool handler: an async function decorated with @mcp.tool() that retrieves a range of elements from a Redis list using the Redis client's lrange method, returns them as a JSON string or an error message.
    @mcp.tool()
    async def lrange(name: str, start: int, stop: int) -> Union[str, List[str]]:
        """Get elements from a Redis list within a specific range.
    
        Returns:
        str: A JSON string containing the list of elements or an error message.
        """
        try:
            r = RedisConnectionManager.get_connection()
            values = r.lrange(name, start, stop)
            if not values:
                return f"List '{name}' is empty or does not exist."
            else:
                return json.dumps(values)
        except RedisError as e:
            return f"Error retrieving values from list '{name}': {str(e)}"
  • The @mcp.tool() decorator registers the lrange function as an MCP tool.
    @mcp.tool()
  • Type hints and docstring define the input schema (name: str, start: int, stop: int) and output (JSON string or list/error str).
    async def lrange(name: str, start: int, stop: int) -> Union[str, List[str]]:
        """Get elements from a Redis list within a specific range.
    
        Returns:
        str: A JSON string containing the list of elements or an error message.
        """
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool returns a JSON string with list elements or an error, which adds some context on output format and error handling. However, it lacks details on permissions, rate limits, side effects (e.g., whether it modifies data), or Redis-specific behaviors (e.g., how negative indices work). For a read operation with zero annotation coverage, this is insufficient.

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 concise and front-loaded, with the core purpose in the first sentence and return details in the second. There is no wasted text, and it efficiently conveys key information. However, it could be slightly more structured by separating purpose from returns more clearly, but this is minor.

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 complexity (a read operation on Redis lists with 3 parameters), no annotations, and an output schema present (which likely covers return values), the description is minimally adequate. It states the purpose and return format but lacks parameter explanations, usage context, and behavioral details. The output schema reduces the need to describe returns, but overall completeness is limited.

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

Parameters2/5

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

Schema description coverage is 0%, meaning parameters are undocumented in the schema. The description does not explain the parameters ('name', 'start', 'stop') beyond implying a 'Redis list' and 'range'. It fails to clarify that 'name' is the list key, 'start' and 'stop' are integer indices (including negative values for reverse indexing), or provide examples. With low coverage, the description does not adequately compensate.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get elements from a Redis list within a specific range.' It specifies the verb ('Get'), resource ('Redis list'), and scope ('within a specific range'), making the intent unambiguous. However, it does not explicitly differentiate from sibling tools like 'lpop', 'rpop', 'lpush', or 'rpush', which also operate on Redis lists, so it misses full sibling differentiation.

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 does not mention when to prefer 'lrange' over other list-related tools (e.g., 'lpop' for popping elements, 'llen' for length) or general data retrieval tools like 'get'. There is no context on prerequisites, exclusions, or typical use cases, leaving the agent without usage direction.

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