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'],
      },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. While 'search' implies a read operation, it doesn't mention permissions needed, rate limits, pagination behavior, or what happens with no results. For a search tool with zero annotation coverage, this leaves significant gaps in understanding its operational characteristics.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's appropriately sized for a straightforward search tool and front-loads the core functionality immediately.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and multiple sibling tools that could overlap in functionality, the description is insufficiently complete. It doesn't explain what the search returns (message objects? summaries?), how results are structured, or how it differs from other message-retrieval tools. For a search operation in a messaging context, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents all three parameters (query, count, sort). The description adds no additional parameter semantics beyond what's in the schema. Baseline 3 is appropriate when the schema does all the parameter documentation work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('search') and resource ('messages') with scope ('across the workspace'), making the purpose immediately understandable. However, it doesn't distinguish this tool from potential sibling search tools (none are listed among siblings, but the agent might expect alternatives like filtering by channel or user).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'get_channel_history' (which might retrieve messages in a specific channel) and 'list_channels' (which could help narrow scope), there's no indication of when search is preferable over more targeted retrieval methods.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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