Skip to main content
Glama
piekstra

Slack MCP Server

by piekstra

get_channel_history

Retrieve message history from a Slack channel by specifying channel ID, time range, and message limit to access past conversations.

Instructions

Get message history for a Slack channel.

Args: channel: Channel ID limit: Maximum number of messages to return oldest: Only messages after this timestamp latest: Only messages before this timestamp

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelYes
limitNo
oldestNo
latestNo

Implementation Reference

  • The main MCP tool handler function for 'get_channel_history'. It instantiates SlackClient and delegates to its get_channel_history method, serializing the result to JSON.
    @mcp.tool()
    async def get_channel_history(
        channel: str, limit: int = 100, oldest: Optional[str] = None, latest: Optional[str] = None
    ) -> str:
        """
        Get message history for a Slack channel.
    
        Args:
            channel: Channel ID
            limit: Maximum number of messages to return
            oldest: Only messages after this timestamp
            latest: Only messages before this timestamp
        """
        try:
            client = SlackClient()
            result = await client.get_channel_history(channel, limit, oldest, latest)
            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 conversations.history endpoint.
    async def get_channel_history(
        self,
        channel: str,
        limit: int = 100,
        oldest: Optional[str] = None,
        latest: Optional[str] = None,
        inclusive: bool = True,
    ) -> Dict[str, Any]:
        """Get message history for a channel."""
        params = {"channel": channel, "limit": limit, "inclusive": inclusive}
    
        if oldest:
            params["oldest"] = oldest
    
        if latest:
            params["latest"] = latest
    
        return await self._make_request("GET", "conversations.history", 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