Skip to main content
Glama

search_messages

Find specific messages in your Slack workspace by entering search terms to locate conversations, information, or discussions across channels.

Instructions

Search for messages across the workspace

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query
countNoNumber of results to return
sortNoSort orderscore

Implementation Reference

  • The main handler function for the 'search_messages' tool. It validates input using searchMessagesSchema, calls Slack's search.messages API via the client, and returns formatted results including messages and total count.
    export async function searchMessages(client: SlackClientWrapper, args: unknown) { const params = searchMessagesSchema.parse(args); return await client.safeCall(async () => { const result = await client.getClient().search.messages({ query: params.query, count: params.count, sort: params.sort, }); return { messages: result.messages, total: result.messages?.total || 0, }; }); }
  • Zod schema used for input validation in the searchMessages handler.
    export const searchMessagesSchema = z.object({ query: z.string().min(1), count: z.number().min(1).max(100).optional().default(20), sort: z.enum(['score', 'timestamp']).optional().default('score'), });
  • src/index.ts:430-430 (registration)
    Registration of the 'search_messages' tool handler in the toolHandlers map, linking the tool name to the searchMessages function from messageTools.
    search_messages: (args) => messageTools.searchMessages(slackClient, args),
  • src/index.ts:264-289 (registration)
    Tool specification in the tools array, including name, description, and inputSchema for the MCP list_tools endpoint.
    { name: 'search_messages', description: 'Search for messages across the workspace', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query', }, count: { type: 'number', description: 'Number of results to return', default: 20, minimum: 1, maximum: 100, }, sort: { type: 'string', enum: ['score', 'timestamp'], description: 'Sort order', default: 'score', }, }, required: ['query'], },

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