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

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)}"

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