slack_search_messages
Find Slack messages by searching for specific text or hashtags across channels to locate relevant conversations and information.
Instructions
Search for messages containing specific text or hashtags.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"query": "<query>"
},
"name": "slack_search_messages"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query (e.g., '#GenAI' or 'workshop idea'). | |
| channel_id | No | Limit search to specific channel. |
Implementation Reference
- src/index.js:742-776 (handler)The handler implementation for slack_search_messages which filters messages from a channel's history based on a search query.
case "slack_search_messages": { const query = args.query; const channelId = args.channel_id; // Note: search.messages requires a user token, not a bot token // For bot tokens, we'll filter messages from history instead if (channelId || DEFAULT_CHANNEL) { const channel = channelId || DEFAULT_CHANNEL; // Get recent history and filter const result = await slack.conversations.history({ channel: channel, limit: 200, }); const messages = (result.messages || []).filter((msg) => msg.text?.toLowerCase().includes(query.toLowerCase()) ); return { content: [ { type: "text", text: JSON.stringify( { query: query, channel: channel, match_count: messages.length, matches: messages.map((msg) => ({ ts: msg.ts, text: msg.text, date: new Date(parseFloat(msg.ts) * 1000).toISOString(), })), }, null, - src/index.js:243-257 (registration)Registration of the slack_search_messages tool, defining its name, description, and input schema.
{ name: "slack_search_messages", description: "Search for messages containing specific text or hashtags.", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query (e.g., '#GenAI' or 'workshop idea').", }, channel_id: { type: "string", description: "Limit search to specific channel.", },