send_formatted_message
Send formatted Slack messages using Block Kit to structure content with interactive elements in specified channels or threads.
Instructions
Send a message with Block Kit formatting
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel | Yes | Channel ID | |
| text | Yes | Fallback text | |
| blocks | Yes | Block Kit blocks array | |
| thread_ts | No | Optional thread timestamp to reply to |
Implementation Reference
- src/tools/messages.ts:103-121 (handler)The core handler function for the 'send_formatted_message' tool. It validates input using Zod schema, then uses the Slack client to post a message with Block Kit blocks support.export async function sendFormattedMessage(client: SlackClientWrapper, args: unknown) { const params = sendFormattedMessageSchema.parse(args); return await client.safeCall(async () => { const result = await client.getClient().chat.postMessage({ channel: params.channel, text: params.text, blocks: params.blocks as any, thread_ts: params.thread_ts, }); return { ok: true, channel: result.channel, ts: result.ts, message: result.message, }; }); }
- src/utils/validators.ts:78-83 (schema)Zod schema used for input validation in the handler, defining parameters: channel, text, blocks (array), optional thread_ts.export const sendFormattedMessageSchema = z.object({ channel: channelIdSchema, text: z.string().min(1), blocks: blocksArraySchema, thread_ts: timestampSchema.optional(), });
- src/index.ts:291-316 (registration)Tool metadata registration including name, description, and JSON inputSchema for the MCP list_tools endpoint.{ name: 'send_formatted_message', description: 'Send a message with Block Kit formatting', inputSchema: { type: 'object', properties: { channel: { type: 'string', description: 'Channel ID', }, text: { type: 'string', description: 'Fallback text', }, blocks: { type: 'array', description: 'Block Kit blocks array', }, thread_ts: { type: 'string', description: 'Optional thread timestamp to reply to', }, }, required: ['channel', 'text', 'blocks'], }, },
- src/index.ts:431-431 (registration)Binds the tool name to the imported handler function from messageTools for the MCP call_tool handler.send_formatted_message: (args) => messageTools.sendFormattedMessage(slackClient, args),