Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

subscribe

Subscribe to Redis channels to receive real-time messages and updates, enabling event-driven communication and data monitoring.

Instructions

Subscribe to a Redis channel.

Args: channel: The Redis channel to subscribe to.

Returns: A success message or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'subscribe' MCP tool. It uses Redis pubsub to subscribe to the specified channel and returns a confirmation or error message. The @mcp.tool() decorator registers it as an MCP tool.
    @mcp.tool()
    async def subscribe(channel: str) -> str:
        """Subscribe to a Redis channel.
    
        Args:
            channel: The Redis channel to subscribe to.
    
        Returns:
            A success message or an error message.
        """
        try:
            r = RedisConnectionManager.get_connection()
            pubsub = r.pubsub()
            pubsub.subscribe(channel)
            return f"Subscribed to channel '{channel}'."
        except RedisError as e:
            return f"Error subscribing to channel '{channel}': {str(e)}"
  • The @mcp.tool() decorator registers the subscribe function as an MCP tool.
    @mcp.tool()
  • The docstring provides the input schema (channel: str) and output description for the subscribe tool.
    """Subscribe to a Redis channel.
    
    Args:
        channel: The Redis channel to subscribe to.
    
    Returns:
        A success message or an error message.
    """
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 offers minimal behavioral insight. It mentions that it 'subscribes to a Redis channel' but doesn't describe what subscription entails (e.g., real-time message reception, blocking behavior, connection requirements, or error conditions). This is inadequate for a tool that likely involves persistent network operations.

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

Conciseness5/5

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

The description is front-loaded with the core purpose in the first sentence, followed by structured 'Args' and 'Returns' sections. Every sentence earns its place without redundancy, making it highly efficient and easy to scan.

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 (involving network subscriptions), no annotations, and an output schema present (which handles return values), the description is minimally adequate. It covers the basic action and parameter but lacks details on behavioral aspects like how messages are delivered or error handling, leaving gaps for an AI agent.

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

Parameters4/5

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

The description adds meaningful context for the single parameter 'channel' by specifying it's 'The Redis channel to subscribe to,' which clarifies its purpose beyond the schema's basic type information. With 0% schema description coverage and only one parameter, this compensates well, though it could note channel naming conventions or restrictions.

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 verb ('Subscribe') and resource ('Redis channel'), making the purpose immediately understandable. It distinguishes from siblings like 'publish' (which sends messages) and 'unsubscribe' (which stops listening), though it doesn't explicitly mention these distinctions in the description text itself.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an active connection), when to choose 'subscribe' over other Redis operations, or what happens after subscription (e.g., how messages are received). The presence of 'unsubscribe' as a sibling tool highlights this gap.

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