slack_post_message
Send messages to Slack channels or direct messages using channel IDs and text content. This tool enables automated communication within Slack workspaces through API integration.
Instructions
Post a new message to a Slack channel or direct message to user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel_id | Yes | The ID of the channel or user to post to | |
| text | Yes | The message text to post |
Implementation Reference
- index.ts:248-264 (registration)Registration of the slack_post_message MCP tool, including title, description, input schema, and handler function that delegates to SlackClient.postMessage.server.registerTool( "slack_post_message", { title: "Post Slack Message", description: "Post a new message to a Slack channel or direct message to user", inputSchema: { channel_id: z.string().describe("The ID of the channel or user to post to"), text: z.string().describe("The message text to post"), }, }, async ({ channel_id, text }) => { const response = await slackClient.postMessage(channel_id, text); return { content: [{ type: "text", text: JSON.stringify(response) }], }; } );
- index.ts:111-122 (handler)The core handler function in SlackClient that executes the Slack API call to post a message using chat.postMessage endpoint.async postMessage(channel_id: string, text: string): Promise<any> { const response = await fetch("https://slack.com/api/chat.postMessage", { method: "POST", headers: this.botHeaders, body: JSON.stringify({ channel: channel_id, text: text, }), }); return response.json(); }
- index.ts:253-256 (schema)Zod input schema definition for the tool parameters: channel_id and text.inputSchema: { channel_id: z.string().describe("The ID of the channel or user to post to"), text: z.string().describe("The message text to post"), },