subscribe
Subscribe to a Redis channel to receive real-time updates. Specify the channel to monitor data changes effectively.
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
| Name | Required | Description | Default |
|---|---|---|---|
| channel | Yes |
Implementation Reference
- src/tools/pub_sub.py:26-42 (handler)The 'subscribe' tool handler: an async function decorated with @mcp.tool() that subscribes to a Redis channel using pubsub and returns a success or error message.@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)}"