Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

unsubscribe

Unsubscribe from a Redis channel by providing its name to stop receiving messages from that channel.

Instructions

Unsubscribe from a Redis channel.

Args: channel: The Redis channel to unsubscribe from.

Returns: A success message or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The 'unsubscribe' tool handler function. Decorated with @mcp.tool(), it gets a Redis connection, creates a pubsub object, and unsubscribes from the given channel.
    @mcp.tool()
    async def unsubscribe(channel: str) -> str:
        """Unsubscribe from a Redis channel.
    
        Args:
            channel: The Redis channel to unsubscribe from.
    
        Returns:
            A success message or an error message.
        """
        try:
            r = RedisConnectionManager.get_connection()
            pubsub = r.pubsub()
            pubsub.unsubscribe(channel)
            return f"Unsubscribed from channel '{channel}'."
        except RedisError as e:
            return f"Error unsubscribing from channel '{channel}': {str(e)}"
  • Input schema for unsubscribe: expects a single 'channel' (string) parameter. Returns a string.
    @mcp.tool()
    async def unsubscribe(channel: str) -> str:
        """Unsubscribe from a Redis channel.
    
        Args:
            channel: The Redis channel to unsubscribe from.
    
        Returns:
            A success message or an error message.
        """
        try:
            r = RedisConnectionManager.get_connection()
            pubsub = r.pubsub()
            pubsub.unsubscribe(channel)
            return f"Unsubscribed from channel '{channel}'."
        except RedisError as e:
            return f"Error unsubscribing from channel '{channel}': {str(e)}"
  • Registered via the @mcp.tool() decorator on line 45. The mcp instance (FastMCP) is defined in src/common/server.py, and modules are auto-loaded by load_tools().
    @mcp.tool()
    async def unsubscribe(channel: str) -> str:
  • load_tools() dynamically imports all modules under src.tools, including pub_sub.py, which triggers the @mcp.tool() decorator registration.
    def load_tools():
        import src.tools as tools_pkg
    
        for _, module_name, _ in pkgutil.iter_modules(tools_pkg.__path__):
            importlib.import_module(f"src.tools.{module_name}")
    
    
    # Initialize FastMCP server
    mcp = FastMCP(
        "Redis MCP Server", dependencies=["redis", "python-dotenv", "numpy", "aiohttp"]
    )
    
    # Load tools
    load_tools()
Behavior2/5

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

Without annotations, the description must disclose behavioral traits. It only states that it returns a success or error message, but does not explain effects on state, idempotency, or error conditions like unsubscribing from a non-existent channel.

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 very short and front-loaded with the core action. It avoids unnecessary detail, though the Returns section could be inferred from output schema. Overall efficient.

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?

For a simple tool with one parameter, the description is moderately complete. It covers the basic purpose and parameter, but lacks behavioral and error context that would be expected for a network operation without annotations.

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?

The input schema has 0% description coverage, so the description must compensate. It merely restates the parameter name and its role ('The Redis channel to unsubscribe from'), adding no extra semantic detail or format constraints beyond the schema.

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 action 'Unsubscribe' and the resource 'Redis channel', which is precise and unambiguous. It effectively distinguishes from the sibling tool 'subscribe' by specifying the opposite operation.

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, such as when a subscription is active or what happens if the channel is not subscribed to. There is no mention of prerequisites or context for use.

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