Skip to main content
Glama
piekstra

Slack MCP Server

by piekstra

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
NameRequiredDescriptionDefault
channelYes
titleNo
textNo
fieldsNo
contextNo
thread_tsNo

Implementation Reference

  • 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)
  • The @mcp.tool() decorator registers the send_formatted_message function as an MCP tool.
    @mcp.tool()
  • 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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/piekstra/slack-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server