Skip to main content
Glama
oregpt

Slack MCP Server

by oregpt

conversations_replies

Retrieve threaded message conversations from Slack channels using channel ID and thread timestamp, with pagination support for handling long discussions.

Instructions

Fetches all messages in a specific thread by channel and thread timestamp. Supports pagination.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accessTokenYesSlack OAuth token (xoxp-... or xoxb-...)
channel_idYesChannel ID (e.g., C1234567890), channel name (#general), or DM (@username)
thread_tsYesMessage timestamp in format 1234567890.123456
limitNoTime range (1d, 7d, 1m, 90d) or message count (e.g., 100)
cursorNoPagination cursor from previous response
include_activity_messagesNoInclude join/leave system messages (default: false)

Implementation Reference

  • The handler function that executes the conversations_replies tool. Validates input, resolves channel ID, calls Slack conversations.replies API, filters messages, and returns formatted response.
    export async function conversationsReplies(args: any): Promise<ToolResponse> {
      try {
        const validated = ConversationsRepliesSchema.parse(args);
        const client = new WebClient(validated.accessToken);
    
        console.log('Fetching thread replies for channel:', validated.channel_id, 'thread:', validated.thread_ts);
    
        // Resolve channel name/username to ID if needed
        const channelId = await resolveChannelId(client, validated.channel_id);
    
        // Parse limit parameter
        const limitParams = parseLimit(validated.limit);
    
        // Fetch thread replies
        const result = await client.conversations.replies({
          channel: channelId,
          ts: validated.thread_ts,
          cursor: validated.cursor,
          ...limitParams
        });
    
        // Filter out activity messages if not requested
        let messages = result.messages || [];
        if (!validated.include_activity_messages) {
          messages = messages.filter((msg: any) => !msg.subtype || !['channel_join', 'channel_leave'].includes(msg.subtype));
        }
    
        return {
          success: true,
          data: {
            messages,
            has_more: result.has_more,
            cursor: result.response_metadata?.next_cursor,
            channel_id: channelId,
            thread_ts: validated.thread_ts
          }
        };
      } 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 schema defining the input parameters and validation for the conversations_replies tool.
    export const ConversationsRepliesSchema = z.object({
      accessToken: z.string().describe("Slack OAuth token (xoxp-... or xoxb-...)"),
      channel_id: z.string().describe("Channel ID (e.g., C1234567890), channel name (#general), or DM (@username)"),
      thread_ts: z.string().describe("Message timestamp in format 1234567890.123456"),
      limit: z.union([z.string(), z.number()]).optional().describe("Time range (1d, 7d, 1m, 90d) or message count (e.g., 100)"),
      cursor: z.string().optional().describe("Pagination cursor from previous response"),
      include_activity_messages: z.boolean().optional().describe("Include join/leave system messages (default: false)")
    });
  • src/index.ts:100-104 (registration)
    Registers the conversations_replies tool in the MCP server's tool list, providing name, description, and input schema.
    {
      name: 'conversations_replies',
      description: 'Fetches all messages in a specific thread by channel and thread timestamp. Supports pagination.',
      inputSchema: zodToMCPSchema(ConversationsRepliesSchema)
    },
  • src/index.ts:133-135 (registration)
    Dispatches execution of the conversations_replies tool in the server's callTool handler switch statement.
    case 'conversations_replies':
      result = await conversationsReplies(args);
      break;

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