Skip to main content
Glama
piekstra

Slack MCP Server

by piekstra

search_messages

Find specific messages in your Slack workspace by entering search queries, with options to sort results by relevance or date and control the number of returned items.

Instructions

Search for messages across the Slack workspace.

Args: query: Search query sort: Sort by 'score' or 'timestamp' sort_dir: Sort direction 'asc' or 'desc' count: Number of results to return

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
sortNotimestamp
sort_dirNodesc
countNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary MCP tool handler for 'search_messages', decorated with @mcp.tool() which also handles registration. It creates a SlackClient instance and calls its search_messages method, returning JSON results.
    @mcp.tool()
    async def search_messages(query: str, sort: str = "timestamp", sort_dir: str = "desc", count: int = 20) -> str:
        """
        Search for messages across the Slack workspace.
    
        Args:
            query: Search query
            sort: Sort by 'score' or 'timestamp'
            sort_dir: Sort direction 'asc' or 'desc'
            count: Number of results to return
        """
        try:
            client = SlackClient()
            result = await client.search_messages(query, sort, sort_dir, count)
            return json.dumps(result, indent=2)
        except Exception as e:
            return json.dumps({"error": str(e)}, indent=2)
  • Helper method in SlackClient class that makes the actual Slack API call to 'search.messages' endpoint with the provided parameters.
    async def search_messages(
        self, query: str, sort: str = "timestamp", sort_dir: str = "desc", count: int = 20
    ) -> Dict[str, Any]:
        """Search for messages across the workspace."""
        params = {"query": query, "sort": sort, "sort_dir": sort_dir, "count": count}
        return await self._make_request("GET", "search.messages", params=params)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool searches messages but doesn't describe key behaviors: what the search covers (e.g., text, metadata, attachments), whether it's paginated, rate limits, authentication needs, or what the output looks like (though an output schema exists). For a search tool with zero annotation coverage, this is a significant gap in transparency.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded: the first sentence states the purpose clearly, followed by a structured Args section. Every sentence earns its place, with no redundant information. It could be slightly more concise by integrating the Args into the main text, but the structure is efficient and readable.

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

Completeness3/5

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

Given the tool's moderate complexity (search with 4 parameters), no annotations, and an output schema present, the description is partially complete. It covers the basic purpose and parameters but lacks behavioral context (e.g., search scope, limitations) and usage guidelines. The output schema mitigates the need to describe return values, but overall, the description is adequate with clear gaps for a search tool in this context.

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 0%, so the schema provides no parameter descriptions. The description adds basic semantics by listing parameters and brief explanations (e.g., 'Search query' for query, 'Sort by 'score' or 'timestamp'' for sort). However, it doesn't fully compensate for the coverage gap—missing details like query syntax, default behaviors beyond schema defaults, or result limits. With 4 parameters and low schema coverage, the description adds some value but remains incomplete.

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 tool's purpose: 'Search for messages across the Slack workspace.' It specifies the verb ('search') and resource ('messages'), and the scope ('across the Slack workspace') helps distinguish it from channel-specific tools like get_channel_history. However, it doesn't explicitly differentiate from other search-related tools (none exist in siblings), so it's not a perfect 5.

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. It doesn't mention prerequisites (e.g., needing specific permissions), compare it to get_channel_history for channel-specific searches, or indicate when not to use it (e.g., for real-time vs. historical searches). The lack of usage context leaves the agent to infer based on tool names alone.

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/piekstra/slack-mcp-server'

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