Skip to main content
Glama
z9905080
by z9905080

slack_post_message

Send messages to Slack channels using the MCP Server for Slack. This tool enables AI assistants to communicate directly within Slack workspaces by posting text content to specified channels.

Instructions

Post a new message to a Slack channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channel_idYesThe ID of the channel to post to
textYesThe message text to post

Implementation Reference

  • The main handler for the slack_post_message tool within the CallToolRequest switch statement. It validates the required arguments (channel_id and text), calls SlackClient.postMessage, and returns the API response.
    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) }], }; }
  • Tool schema definition for slack_post_message, specifying name, description, input properties (channel_id, text), and required fields.
    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"], }, };
  • Helper method in SlackClient class that performs the actual 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:567-582 (registration)
    Registration of the tool via inclusion of postMessageTool in the tools list returned by the ListToolsRequest handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => { console.log("Received ListToolsRequest"); return { tools: [ listChannelsTool, postMessageTool, replyToThreadTool, addReactionTool, getChannelHistoryTool, getThreadRepliesTool, getUsersTool, getUserProfileTool, lookupUserByEmailTool, ], }; });
  • TypeScript interface defining the input arguments for the slack_post_message tool.
    interface PostMessageArgs { channel_id: string; text: string; }

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/z9905080/mcp-slack'

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