publish
Send messages to a Redis channel by specifying the target channel and content. Facilitates communication and data distribution within Redis environments.
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
| Name | Required | Description | Default |
|---|---|---|---|
| channel | Yes | ||
| message | Yes |
Implementation Reference
- src/tools/pub_sub.py:7-23 (handler)The 'publish' tool handler: an async function decorated with @mcp.tool() that publishes a message to a Redis channel via RedisConnectionManager, with error handling for RedisError. The docstring provides the tool description, args, and return info used for schema.@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)}"
- src/tools/pub_sub.py:7-7 (registration)Registration of the 'publish' tool using the @mcp.tool() decorator from src.common.server.mcp.@mcp.tool()