Skip to main content
Glama
AVIMBU

Slack MCP Server

by AVIMBU

slack_post_message

Send messages to Slack channels using channel IDs and text content to facilitate team communication.

Instructions

Post a new message to a Slack channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channel_idYesThe Channel ID to post the message to
textYesThe message text to post

Implementation Reference

  • Handler for the slack_post_message tool within the CallToolRequest switch statement. It validates the input arguments, calls slackClient.postMessage, and returns the JSON-stringified 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 definition including name, description, and input schema for slack_post_message.
    export 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 Channel ID to post the message to",
          },
          text: {
            type: "string",
            description: "The message text to post",
          },
        },
        required: ["channel_id", "text"],
      },
    };
  • src/index.ts:25-29 (registration)
    Registration of the slack_post_message tool (via postMessageTool) in the ListToolsRequest handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [getUsersTool, postMessageTool],
      };
    });
  • Core helper function in SlackClient that performs the HTTP POST to Slack's chat.postMessage API.
    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();
    }
  • TypeScript interface defining the input arguments for the slack_post_message tool.
    export interface PostMessageArgs {
      channel_id: string;
      text: string;
    }
Install Server

Other Tools

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

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