Skip to main content
Glama
piekstra

Slack MCP Server

by piekstra

search_messages

Search for messages in a Slack workspace using a query, with options to sort by relevance or timestamp and control the number of results returned.

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
countNo
queryYes
sortNotimestamp
sort_dirNodesc

Implementation Reference

  • MCP tool handler for search_messages that creates a SlackClient instance, calls its search_messages method with provided parameters, and returns the JSON-formatted result or error.
    @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)
  • SlackClient helper method that makes an authenticated GET request to Slack's search.messages API endpoint with the search 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