Skip to main content
Glama

get_channel_history

Retrieve message history from Slack channels by specifying channel ID, time range, and message limits to analyze conversations and track discussions.

Instructions

Get message history from a channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelYesChannel ID
limitNoMaximum number of messages to return
oldestNoStart of time range (timestamp)
latestNoEnd of time range (timestamp)

Implementation Reference

  • The handler function implementing the get_channel_history tool logic. It validates input with Zod schema, calls Slack's conversations.history API, and returns formatted messages with pagination info.
    export async function getChannelHistory(client: SlackClientWrapper, args: unknown) { const params = getChannelHistorySchema.parse(args); return await client.safeCall(async () => { const result = await client.getClient().conversations.history({ channel: params.channel, limit: params.limit, oldest: params.oldest, latest: params.latest, cursor: params.cursor, }); return { messages: result.messages || [], has_more: result.has_more, next_cursor: result.response_metadata?.next_cursor, }; }); }
  • Zod schema defining and validating the input parameters for the get_channel_history tool, including channel ID, optional limit, time ranges, and cursor.
    export const getChannelHistorySchema = z.object({ channel: channelIdSchema, limit: z.number().min(1).max(1000).optional().default(100), oldest: timestampSchema.optional(), latest: timestampSchema.optional(), cursor: z.string().optional(), });
  • src/index.ts:236-263 (registration)
    Registration of the get_channel_history tool in the list_tools response, providing name, description, and JSON input schema.
    name: 'get_channel_history', description: 'Get message history from a channel', inputSchema: { type: 'object', properties: { channel: { type: 'string', description: 'Channel ID', }, limit: { type: 'number', description: 'Maximum number of messages to return', default: 100, minimum: 1, maximum: 1000, }, oldest: { type: 'string', description: 'Start of time range (timestamp)', }, latest: { type: 'string', description: 'End of time range (timestamp)', }, }, required: ['channel'], }, },
  • src/index.ts:429-429 (registration)
    Binding of the get_channel_history tool name to its handler function in the toolHandlers map for call_tool requests.
    get_channel_history: (args) => messageTools.getChannelHistory(slackClient, args),

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/Hais/slack-bot-mcp'

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