Skip to main content
Glama
oregpt

Slack MCP Server

by oregpt

conversations_add_message

Post messages to Slack channels, threads, or direct messages using markdown or plain text formatting. Requires OAuth authentication and channel targeting.

Instructions

Posts a message to a channel, thread, or DM. Supports markdown and plain text. NOTE: Disabled by default for safety - set SLACK_MCP_ADD_MESSAGE_TOOL environment variable to enable.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accessTokenYesSlack OAuth token (xoxp-... or xoxb-...) with chat:write scope
channel_idYesTarget channel ID, name (#general), or DM (@username)
thread_tsNoThread timestamp; omit to post to channel directly
payloadYesMessage content to post
content_typeNoContent format (default: text/markdown)

Implementation Reference

  • Main execution logic for conversations_add_message tool: validates args with schema, resolves channel ID, checks env-enabled channels, posts message via Slack chat.postMessage, handles errors.
    export async function conversationsAddMessage(args: any): Promise<ToolResponse> {
      try {
        // Safety check - require explicit enable
        const enabledChannels = process.env.SLACK_MCP_ADD_MESSAGE_TOOL;
        if (!enabledChannels) {
          return {
            success: false,
            error: 'Message posting is disabled by default for safety. Set SLACK_MCP_ADD_MESSAGE_TOOL environment variable to enable.'
          };
        }
    
        const validated = ConversationsAddMessageSchema.parse(args);
        const client = new WebClient(validated.accessToken);
    
        console.log('Posting message to channel:', validated.channel_id);
    
        // Resolve channel name/username to ID if needed
        const channelId = await resolveChannelId(client, validated.channel_id);
    
        // Check if channel is in enabled list (if not '*')
        if (enabledChannels !== '*') {
          const allowedChannels = enabledChannels.split(',').map(c => c.trim());
          if (!allowedChannels.includes(channelId) && !allowedChannels.includes(validated.channel_id)) {
            return {
              success: false,
              error: `Message posting not enabled for channel: ${validated.channel_id}`
            };
          }
        }
    
        // Post message
        const result = await client.chat.postMessage({
          channel: channelId,
          text: validated.payload,
          thread_ts: validated.thread_ts,
          mrkdwn: validated.content_type === 'text/markdown'
        });
    
        return {
          success: true,
          data: {
            ok: result.ok,
            channel: result.channel,
            ts: result.ts,
            message: result.message
          }
        };
      } catch (error: any) {
        if (error.name === 'ZodError') {
          return { success: false, error: `Validation error: ${error.errors.map((e: any) => e.message).join(', ')}` };
        }
        return handleSlackError(error);
      }
    }
  • Zod input schema for conversations_add_message tool, defining parameters: accessToken, channel_id, optional thread_ts, payload, content_type.
     * Schema for conversations_add_message tool
     * Posts messages to channels, threads, or DMs
     * Note: Disabled by default for safety - requires configuration to enable
     */
    export const ConversationsAddMessageSchema = z.object({
      accessToken: z.string().describe("Slack OAuth token (xoxp-... or xoxb-...) with chat:write scope"),
      channel_id: z.string().describe("Target channel ID, name (#general), or DM (@username)"),
      thread_ts: z.string().optional().describe("Thread timestamp; omit to post to channel directly"),
      payload: z.string().describe("Message content to post"),
      content_type: z.enum(['text/markdown', 'text/plain']).optional().describe("Content format (default: text/markdown)")
    });
  • src/index.ts:106-108 (registration)
    Tool registration in MCP server's listTools response: specifies name, description, and converts Zod schema to MCP inputSchema.
    name: 'conversations_add_message',
    description: 'Posts a message to a channel, thread, or DM. Supports markdown and plain text. NOTE: Disabled by default for safety - set SLACK_MCP_ADD_MESSAGE_TOOL environment variable to enable.',
    inputSchema: zodToMCPSchema(ConversationsAddMessageSchema)
  • src/index.ts:137-139 (registration)
    Dispatch logic in MCP callTool handler: routes 'conversations_add_message' calls to the conversationsAddMessage function.
    case 'conversations_add_message':
      result = await conversationsAddMessage(args);
      break;
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively communicates critical behavioral traits: the safety restriction (disabled by default requiring environment variable), the mutation nature ('Posts a message'), and format support (markdown/plain text). However, it lacks details about rate limits, error conditions, or response format that would be helpful for a write operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with only two sentences, both of which earn their place. The first sentence establishes core functionality, the second provides critical safety information. No wasted words, and the most important information (the tool's purpose) is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description provides basic but incomplete context. It covers the core action and safety restriction adequately, but lacks information about return values, error handling, permissions beyond the token scope mentioned in the schema, or how it differs from potential alternative messaging approaches. The safety note is valuable but doesn't fully compensate for missing behavioral details.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the input schema already documents all 5 parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain parameter relationships, provide examples, or clarify edge cases. The baseline score of 3 reflects adequate but minimal value addition from the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Posts a message') and target resources ('to a channel, thread, or DM'), distinguishing it from sibling tools like channels_list (listing) or conversations_history (reading). It includes additional functionality details ('Supports markdown and plain text') that further clarify its purpose beyond basic posting.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context through the safety note about being disabled by default, but does not explicitly state when to use this tool versus alternatives. No guidance is provided on when to choose this tool over other messaging approaches or sibling tools, leaving usage decisions to inference from the purpose statement alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/oregpt/Agenticledger_MCP_Slack'

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