send_formatted_message
Send structured Slack messages with Block Kit formatting, including headers, text, fields, and context, to specified channels or threads.
Instructions
Send a formatted message using Block Kit with common elements.
Args: channel: Channel ID or name title: Header text (optional) text: Main message text (optional) fields: Comma-separated fields for side-by-side display (optional) context: Context text at bottom (optional) thread_ts: Thread timestamp for replies (optional)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel | Yes | ||
| title | No | ||
| text | No | ||
| fields | No | ||
| context | No | ||
| thread_ts | No |
Implementation Reference
- slack_mcp/server.py:747-793 (handler)The handler function for the 'send_formatted_message' MCP tool, decorated with @mcp.tool() for automatic registration. It constructs Slack Block Kit blocks based on input parameters and sends the message via SlackClient, returning JSON result or error.@mcp.tool() async def send_formatted_message( channel: str, title: Optional[str] = None, text: Optional[str] = None, fields: Optional[str] = None, context: Optional[str] = None, thread_ts: Optional[str] = None ) -> str: """ Send a formatted message using Block Kit with common elements. Args: channel: Channel ID or name title: Header text (optional) text: Main message text (optional) fields: Comma-separated fields for side-by-side display (optional) context: Context text at bottom (optional) thread_ts: Thread timestamp for replies (optional) """ try: blocks = [] if title: blocks.append(BlockKitBuilder.header(title)) if text: blocks.append(BlockKitBuilder.section(text)) if fields: field_list = [field.strip() for field in fields.split(",")] blocks.append(BlockKitBuilder.fields_section(field_list)) if context: blocks.append(BlockKitBuilder.context([context])) if not blocks: return json.dumps({"error": "At least one of title, text, fields, or context must be provided"}, indent=2) fallback_text = title or text or "Formatted message" client = SlackClient() result = await client.send_message(channel, fallback_text, thread_ts, blocks) return json.dumps(result, indent=2) except Exception as e: return json.dumps({"error": str(e)}, indent=2)
- slack_mcp/server.py:747-747 (registration)The @mcp.tool() decorator registers the send_formatted_message function as an MCP tool.@mcp.tool()
- slack_mcp/server.py:749-754 (schema)Input schema defined by function type hints and default values, used by MCP for tool parameter schema.channel: str, title: Optional[str] = None, text: Optional[str] = None, fields: Optional[str] = None, context: Optional[str] = None, thread_ts: Optional[str] = None