send_message
Send messages to Slack channels with text, rich formatting using Block Kit, and threaded replies for organized team communication.
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 |
|---|---|---|---|
| channel | Yes | ||
| text | Yes | ||
| thread_ts | No | ||
| blocks | No |
Implementation Reference
- slack_mcp/server.py:290-307 (handler)The main handler function for the 'send_message' MCP tool. It creates a SlackClient instance, parses optional blocks JSON parameter, calls the underlying SlackClient.send_message method, and returns the API response as formatted JSON or an error message.@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 underlying helper method in SlackClient class that constructs the request payload and calls the Slack chat.postMessage API endpoint via _make_request to send the 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)