Skip to main content
Glama
zencoderai

Slack

by zencoderai

Get Slack Channel History

slack_get_channel_history

Retrieve recent messages from a Slack channel by providing its channel ID. Optionally specify the number of messages to fetch, with a default of 10, for quick access to conversation history.

Instructions

Get recent messages from a channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channel_idYesThe ID of the channel
limitNoNumber of messages to retrieve (default 10)

Implementation Reference

  • The tool registration and handler for 'slack_get_channel_history'. It registers the tool on the MCP server, defines the input schema (channel_id and optional limit), and the handler calls slackClient.getChannelHistory().
    server.registerTool(
      "slack_get_channel_history",
      {
        title: "Get Slack Channel History",
        description: "Get recent messages from a channel",
        inputSchema: {
          channel_id: z.string().describe("The ID of the channel"),
          limit: z.number().optional().default(10).describe("Number of messages to retrieve (default 10)"),
        },
      },
      async ({ channel_id, limit }) => {
        const response = await slackClient.getChannelHistory(channel_id, limit);
        return {
          content: [{ type: "text", text: JSON.stringify(response) }],
        };
      }
    );
  • The SlackClient.getChannelHistory() method that executes the actual API call to Slack's conversations.history endpoint.
    async getChannelHistory(
      channel_id: string,
      limit: number = 10,
    ): Promise<any> {
      const params = new URLSearchParams({
        channel: channel_id,
        limit: limit.toString(),
      });
    
      const response = await fetch(
        `https://slack.com/api/conversations.history?${params}`,
        { headers: this.botHeaders },
      );
    
      return response.json();
    }
  • TypeScript interface defining the input arguments for GetChannelHistory: channel_id (string) and optional limit (number).
    interface GetChannelHistoryArgs {
      channel_id: string;
      limit?: number;
    }
  • index.ts:304-320 (registration)
    Registration of the 'slack_get_channel_history' tool via server.registerTool() on the McpServer instance.
    server.registerTool(
      "slack_get_channel_history",
      {
        title: "Get Slack Channel History",
        description: "Get recent messages from a channel",
        inputSchema: {
          channel_id: z.string().describe("The ID of the channel"),
          limit: z.number().optional().default(10).describe("Number of messages to retrieve (default 10)"),
        },
      },
      async ({ channel_id, limit }) => {
        const response = await slackClient.getChannelHistory(channel_id, limit);
        return {
          content: [{ type: "text", text: JSON.stringify(response) }],
        };
      }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description merely says 'get recent messages', which implies a read-only operation but does not explicitly confirm that no state is changed. It lacks details about return format, ordering (e.g., chronological or reverse), pagination, or metadata included. With no annotations, the description carries full burden but fails to disclose important behavioral traits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description consists of a single, short sentence that is front-loaded and to the point. However, it may be overly terse, missing an opportunity to add value without significant length. Still, it avoids redundancy and wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the absence of an output schema, the description should explain what 'recent messages' means (e.g., time window, ordering) and whether pagination is supported. It does not address these aspects, leaving the agent without sufficient context to use the tool effectively. Sibling tools suggest more detailed descriptions might be needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has 100% description coverage, so the schema already explains both parameters. The description adds no additional meaning for the parameters beyond what they already have. Therefore, the baseline score of 3 is appropriate, as it neither improves nor degrades parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states that the tool retrieves recent messages from a channel, which matches the name and title. It distinguishes from sibling tools like 'slack_get_thread_replies' or 'slack_add_reaction', as it explicitly targets channel history. However, it could be more specific about the resource (e.g., 'get messages' instead of 'get channel history').

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't specify that this tool should be used for channel messages rather than thread replies (handled by 'slack_get_thread_replies'). There are no context conditions or exclusions mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/zencoderai/slack-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server