Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

publish

Send messages to Redis channels for real-time communication and data distribution in applications.

Instructions

Publish a message to a Redis channel.

Args: channel: The Redis channel to publish to. message: The message to send.

Returns: A success message or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelYes
messageYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'publish' MCP tool. It is decorated with @mcp.tool() which registers it as an MCP tool. The function publishes a message to a specified Redis channel and returns a success or error message.
    @mcp.tool()
    async def publish(channel: str, message: str) -> str:
        """Publish a message to a Redis channel.
    
        Args:
            channel: The Redis channel to publish to.
            message: The message to send.
    
        Returns:
            A success message or an error message.
        """
        try:
            r = RedisConnectionManager.get_connection()
            r.publish(channel, message)
            return f"Message published to channel '{channel}'."
        except RedisError as e:
            return f"Error publishing message to channel '{channel}': {str(e)}"
  • The @mcp.tool() decorator registers the publish function as an MCP tool.
    @mcp.tool()
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions that the tool 'publishes' (implying a write operation) and describes basic return values, but doesn't cover important aspects like authentication requirements, rate limits, message persistence, or whether this is a fire-and-forget operation versus requiring acknowledgment.

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 efficiently structured with a clear purpose statement followed by Args and Returns sections. Every sentence serves a purpose, though the return value description could be more specific. The structure helps with quick scanning and understanding.

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 2-parameter tool with no annotations but with an output schema (which handles return value documentation), the description provides adequate basic information. However, as a messaging tool that likely has behavioral nuances (delivery guarantees, error conditions, etc.), it should provide more context about how publishing works in this Redis implementation.

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?

Schema description coverage is 0%, so the schema provides no parameter documentation. The description compensates by listing both parameters with brief explanations ('The Redis channel to publish to', 'The message to send'), establishing basic semantics. However, it doesn't provide format examples, constraints, or channel naming conventions that would be helpful.

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 ('Publish') and resource ('a message to a Redis channel'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'subscribe' or 'xadd' which also involve Redis messaging, so it doesn't reach the highest clarity level.

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 like 'subscribe' for receiving messages or 'xadd' for stream publishing. It lacks any context about appropriate use cases or prerequisites, offering only basic parameter documentation.

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