get_channel_history
Retrieve message history from a Slack channel by specifying the channel ID, message limit, and timestamps for filtering. Manage conversations and analyze data effectively.
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 | ||
| latest | No | ||
| limit | No | ||
| oldest | No |
Implementation Reference
- slack_mcp/server.py:347-366 (handler)MCP tool handler for get_channel_history. Creates SlackClient instance, calls the client's get_channel_history method, and returns JSON string of the result or error.@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-150 (helper)SlackClient helper method that makes the actual API request to Slack's conversations.history endpoint with the provided parameters.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)