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
| Name | Required | Description | Default |
|---|---|---|---|
| channel_id | Yes | 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 | No | Pagination cursor for next page of results | |
| limit | No | Number of messages to retrieve (default 100) |
Implementation Reference
- src/index.ts:252-269 (handler)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) }], }; }
- src/schemas.ts:116-134 (schema)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), },