Skip to main content
Glama
Stig-Johnny

Slack Notifications MCP Server

by Stig-Johnny

search_messages

Find Slack messages containing specified text and return matching results with an optional limit on the number of messages.

Instructions

Search for messages in Slack containing specific text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query (e.g., 'build failed', 'Cuti-E-Admin')
limitNoMaximum number of results (default: 10)

Implementation Reference

  • index.js:87-105 (registration)
    Tool 'search_messages' is registered in the ListToolsRequestSchema handler with name, description, and inputSchema.
    {
      name: "search_messages",
      description: "Search for messages in Slack containing specific text",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Search query (e.g., 'build failed', 'Cuti-E-Admin')",
          },
          limit: {
            type: "number",
            description: "Maximum number of results (default: 10)",
            default: 10,
          },
        },
        required: ["query"],
      },
    },
  • Input schema for search_messages: requires 'query' (string), optional 'limit' (number, default 10).
      name: "search_messages",
      description: "Search for messages in Slack containing specific text",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Search query (e.g., 'build failed', 'Cuti-E-Admin')",
          },
          limit: {
            type: "number",
            description: "Maximum number of results (default: 10)",
            default: 10,
          },
        },
        required: ["query"],
      },
    },
  • Handler for 'search_messages' tool. Calls Slack search.messages API with the query and limit, formats results with timestamp, channel, text, and user. Handles missing_scope error for search:read permission.
    case "search_messages": {
      const query = args?.query;
      if (!query) {
        return {
          content: [
            {
              type: "text",
              text: "Error: query parameter is required",
            },
          ],
        };
      }
    
      const limit = Math.min(args?.limit || 10, 100);
    
      try {
        const result = await slack.search.messages({
          query: query,
          count: limit,
          sort: "timestamp",
          sort_dir: "desc",
        });
    
        const matches = (result.messages?.matches || []).map((match) => ({
          timestamp: new Date(parseFloat(match.ts) * 1000).toISOString(),
          channel: match.channel?.name,
          text: match.text?.substring(0, 500),
          user: match.user,
        }));
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({ results: matches, total: result.messages?.total || 0 }, null, 2),
            },
          ],
        };
      } catch (error) {
        // Search requires additional OAuth scopes
        if (error.data?.error === "missing_scope") {
          return {
            content: [
              {
                type: "text",
                text: "Error: Bot token missing 'search:read' scope. Add it in your Slack App settings.",
              },
            ],
          };
        }
        throw error;
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It only states 'Search for messages' without mentioning return format, pagination, rate limits, scope (all channels vs. specific ones), or any side effects. This is a significant gap for a search tool.

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

Conciseness3/5

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

The description is a single concise sentence (7 words), but it is underspecified. While not verbose, it lacks sufficient detail for an agent to use the tool correctly. The conciseness comes at the expense of completeness.

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 the tool's simplicity (2 parameters, no output schema) and no annotations, the description is incomplete. It does not specify the scope of the search (e.g., all channels, user messages), sort order, or pagination behavior. The schema provides some detail for parameters, but the overall context is missing.

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?

The input schema covers both parameters with descriptions (100% coverage). Baseline is 3. The description adds the context that the tool searches for messages containing the query text, but this is already implied by the schema's parameter description (e.g., 'Search query'). No additional meaning beyond the schema.

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

Purpose5/5

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

The description clearly states the tool's action (search), resource (messages in Slack), and scope (containing specific text). It differentiates from siblings like 'get_channel_messages' which retrieves messages from a channel, and 'send_message' which sends messages.

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 such as 'get_channel_messages' or 'check_build_status'. There is no mention of prerequisites, context, or exclusion criteria.

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/Stig-Johnny/slack-notifications-mcp'

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