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

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)

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