unsubscribe
Stop receiving messages from a specific Redis channel by unsubscribing from it, managing your data subscriptions effectively.
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
| Name | Required | Description | Default |
|---|---|---|---|
| channel | Yes |
Implementation Reference
- src/tools/pub_sub.py:45-61 (handler)The main handler function for the 'unsubscribe' tool. It uses Redis pubsub to unsubscribe from the specified channel and returns a success or error message. Registered via @mcp.tool() decorator.@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)}"