Skip to main content
Glama
ubie-oss

Slack MCP Server

by ubie-oss

slack_get_channel_history

Retrieve chronological messages from a Slack channel for browsing conversation flow, including all messages with pagination support.

Instructions

Get messages from a channel in chronological order. Use this when: 1) You need the latest conversation flow without specific filters, 2) You want ALL messages including bot/automation messages, 3) You need to browse messages sequentially with pagination. Do NOT use if you have specific search criteria (user, keywords, dates) - use slack_search_messages instead.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channel_idYesThe ID of the channel. Use this tool for: browsing latest messages without filters, getting ALL messages including bot/automation messages, sequential pagination. If you need to search by user, keywords, or dates, use slack_search_messages instead.
cursorNoPagination cursor for next page of results
limitNoNumber of messages to retrieve (default 100)

Implementation Reference

  • The handler implementation that parses input arguments, calls Slack's conversations.history API to fetch channel messages, validates the response, and returns the formatted result.
    case 'slack_get_channel_history': {
      const args = GetChannelHistoryRequestSchema.parse(
        request.params.arguments
      );
      const response = await slackClient.conversations.history({
        channel: args.channel_id,
        limit: args.limit,
        cursor: args.cursor,
      });
      if (!response.ok) {
        throw new Error(`Failed to get channel history: ${response.error}`);
      }
      const parsedResponse =
        ConversationsHistoryResponseSchema.parse(response);
      return {
        content: [{ type: 'text', text: JSON.stringify(parsedResponse) }],
      };
    }
  • Zod schema defining the input parameters for the slack_get_channel_history tool, including channel_id, optional cursor for pagination, and optional limit.
    export const GetChannelHistoryRequestSchema = z.object({
      channel_id: z
        .string()
        .describe(
          'The ID of the channel. Use this tool for: browsing latest messages without filters, getting ALL messages including bot/automation messages, sequential pagination. If you need to search by user, keywords, or dates, use slack_search_messages instead.'
        ),
      cursor: z
        .string()
        .optional()
        .describe('Pagination cursor for next page of results'),
      limit: z
        .number()
        .int()
        .min(1)
        .max(1000) // Align with Slack API's default limit
        .optional()
        .default(100) // The reference repository uses 10, but aligning with list_channels etc., set to 100
        .describe('Number of messages to retrieve (default 100)'),
    });
  • src/index.ts:136-141 (registration)
    Registration of the slack_get_channel_history tool in the listTools response, including name, detailed description, and reference to the input schema.
    {
      name: 'slack_get_channel_history',
      description:
        'Get messages from a channel in chronological order. Use this when: 1) You need the latest conversation flow without specific filters, 2) You want ALL messages including bot/automation messages, 3) You need to browse messages sequentially with pagination. Do NOT use if you have specific search criteria (user, keywords, dates) - use slack_search_messages instead.',
      inputSchema: zodToJsonSchema(GetChannelHistoryRequestSchema),
    },

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

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