send_message
Send messages to Slack channels, including replies in threads and rich formatting with Block Kit. Use channel ID or name, message text, and optional JSON blocks for structured content.
Instructions
Send a message to a Slack channel.
Args: channel: Channel ID or name text: Message text (fallback text for notifications) thread_ts: Thread timestamp for replies blocks: JSON string of Block Kit blocks for rich formatting
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| blocks | No | ||
| channel | Yes | ||
| text | Yes | ||
| thread_ts | No |
Implementation Reference
- slack_mcp/server.py:290-307 (handler)The primary MCP tool handler for 'send_message'. It accepts channel, text, optional thread_ts and blocks (JSON string), instantiates SlackClient, parses blocks, calls the client's send_message method, and returns the JSON-formatted result or error.@mcp.tool() async def send_message(channel: str, text: str, thread_ts: Optional[str] = None, blocks: Optional[str] = None) -> str: """ Send a message to a Slack channel. Args: channel: Channel ID or name text: Message text (fallback text for notifications) thread_ts: Thread timestamp for replies blocks: JSON string of Block Kit blocks for rich formatting """ try: client = SlackClient() blocks_data = json.loads(blocks) if blocks else None result = await client.send_message(channel, text, thread_ts, blocks_data) return json.dumps(result, indent=2) except Exception as e: return json.dumps({"error": str(e)}, indent=2)
- slack_mcp/server.py:102-114 (helper)The SlackClient helper method that constructs the request payload and calls the Slack chat.postMessage API endpoint to send the actual message.async def send_message( self, channel: str, text: str, thread_ts: Optional[str] = None, blocks: Optional[List[Dict[str, Any]]] = None ) -> Dict[str, Any]: """Send a message to a channel.""" data = {"channel": channel, "text": text} if thread_ts: data["thread_ts"] = thread_ts if blocks: data["blocks"] = blocks return await self._make_request("POST", "chat.postMessage", json_data=data)