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

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. """

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