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
| Name | Required | Description | Default |
|---|---|---|---|
| channel | Yes | ||
| limit | No | ||
| oldest | No | ||
| latest | No |
Implementation Reference
- slack_mcp/server.py:347-365 (handler)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)
- slack_mcp/server.py:132-149 (helper)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)