slack_post_message
Send messages to Slack channels using channel IDs and text content to facilitate team communication and information sharing.
Instructions
Post a new message to a Slack channel
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel_id | Yes | The ID of the channel to post to | |
| text | Yes | The message text to post |
Implementation Reference
- index.ts:74-91 (schema)Tool definition including name, description, and input schema for slack_post_message.const postMessageTool: Tool = { name: "slack_post_message", description: "Post a new message to a Slack channel", inputSchema: { type: "object", properties: { channel_id: { type: "string", description: "The ID of the channel to post to", }, text: { type: "string", description: "The message text to post", }, }, required: ["channel_id", "text"], }, };
- index.ts:407-421 (handler)MCP CallToolRequest handler case for slack_post_message: validates arguments and invokes SlackClient.postMessage.case "slack_post_message": { const args = request.params.arguments as unknown as PostMessageArgs; if (!args.channel_id || !args.text) { throw new Error( "Missing required arguments: channel_id and text", ); } const response = await slackClient.postMessage( args.channel_id, args.text, ); return { content: [{ type: "text", text: JSON.stringify(response) }], }; }
- index.ts:245-257 (helper)Core implementation that sends POST request to Slack chat.postMessage API endpoint.async postMessage(channel_id: string, text: string): Promise<any> { const response = await fetch("https://slack.com/api/chat.postMessage", { method: "POST", headers: this.headers, body: JSON.stringify({ channel: channel_id, text: text, as_user: this.isUserToken }), }); return response.json(); }
- index.ts:535-544 (registration)Registration of slack_post_message tool (as postMessageTool) in the ListToolsRequest handler.tools: [ listChannelsTool, postMessageTool, replyToThreadTool, addReactionTool, getChannelHistoryTool, getThreadRepliesTool, getUsersTool, getUserProfileTool, ],
- index.ts:17-20 (schema)TypeScript interface defining input arguments for slack_post_message tool.interface PostMessageArgs { channel_id: string; text: string; }