slack_read_messages
Retrieve Slack channel messages from recent days or specific timestamps to access captured content from your inbox.
Instructions
Read messages from a Slack channel. Returns messages from the last N days or since a specific timestamp. Use this to pull captured content from the inbox.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel_id | No | The Slack channel ID. Defaults to configured inbox channel. | |
| days_back | No | Number of days of history to fetch. Default is 7. | |
| oldest | No | Unix timestamp. If provided, only messages after this time are returned. | |
| limit | No | Maximum number of messages to return. Default 100. |
Implementation Reference
- src/index.js:277-347 (handler)Handler logic for 'slack_read_messages' tool, which fetches Slack conversation history using the Slack Web API.
case "slack_read_messages": { const channelId = args.channel_id || DEFAULT_CHANNEL; const daysBack = args.days_back || 7; const limit = args.limit || 100; if (!channelId) { return { content: [ { type: "text", text: "Error: No channel ID provided and no default channel configured.", }, ], }; } // Calculate oldest timestamp const oldest = args.oldest || String(Math.floor(Date.now() / 1000) - daysBack * 24 * 60 * 60); const result = await slack.conversations.history({ channel: channelId, oldest: oldest, limit: limit, inclusive: true, }); const messages = result.messages || []; // Format messages with files info const formattedMessages = messages.map((msg) => { let formatted = { ts: msg.ts, text: msg.text, user: msg.user, date: new Date(parseFloat(msg.ts) * 1000).toISOString(), thread_ts: msg.thread_ts, reply_count: msg.reply_count || 0, }; if (msg.files && msg.files.length > 0) { formatted.files = msg.files.map((f) => ({ id: f.id, name: f.name, mimetype: f.mimetype, size: f.size, url_private: f.url_private, })); } return formatted; }); return { content: [ { type: "text", text: JSON.stringify( { channel: channelId, message_count: formattedMessages.length, messages: formattedMessages.reverse(), // Chronological order }, null, 2 ), }, ], }; } - src/index.js:67-96 (registration)Definition and schema registration for the 'slack_read_messages' tool.
{ name: "slack_read_messages", description: "Read messages from a Slack channel. Returns messages from the last N days or since a specific timestamp. Use this to pull captured content from the inbox.", inputSchema: { type: "object", properties: { channel_id: { type: "string", description: "The Slack channel ID. Defaults to configured inbox channel.", }, days_back: { type: "number", description: "Number of days of history to fetch. Default is 7.", }, oldest: { type: "string", description: "Unix timestamp. If provided, only messages after this time are returned.", }, limit: { type: "number", description: "Maximum number of messages to return. Default 100.", }, }, required: [], }, },