Skip to main content
Glama
zencoderai

Slack

by zencoderai

List Slack Channels

slack_list_channels

List public and private channels that the bot is a member of or pre-defined channels in a Slack workspace, supporting pagination via limit and cursor.

Instructions

List public and private channels that the bot is a member of, or pre-defined channels in the workspace with pagination

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of channels to return (default 100, max 200)
cursorNoPagination cursor for next page of results

Implementation Reference

  • The handler function for slack_list_channels tool. Calls slackClient.getChannels() with limit and cursor, returns JSON-stringified response.
    server.registerTool(
      "slack_list_channels",
      {
        title: "List Slack Channels",
        description: "List public and private channels that the bot is a member of, or pre-defined channels in the workspace with pagination",
        inputSchema: {
          limit: z.number().optional().default(100).describe("Maximum number of channels to return (default 100, max 200)"),
          cursor: z.string().optional().describe("Pagination cursor for next page of results"),
        },
      },
      async ({ limit, cursor }) => {
        const response = await slackClient.getChannels(limit, cursor);
        return {
          content: [{ type: "text", text: JSON.stringify(response) }],
        };
      }
    );
  • The SlackClient.getChannels() method that executes the actual Slack API calls (conversations.list or conversations.info for predefined channels).
    async getChannels(limit: number = 100, cursor?: string): Promise<any> {
      const predefinedChannelIds = process.env.SLACK_CHANNEL_IDS;
      if (!predefinedChannelIds) {
        const params = new URLSearchParams({
          types: "public_channel,private_channel",
          exclude_archived: "true",
          limit: Math.min(limit, 200).toString(),
          team_id: process.env.SLACK_TEAM_ID!,
        });
    
        if (cursor) {
          params.append("cursor", cursor);
        }
    
        const response = await fetch(
          `https://slack.com/api/conversations.list?${params}`,
          { headers: this.botHeaders },
        );
    
        return response.json();
      }
    
      const predefinedChannelIdsArray = predefinedChannelIds.split(",").map((id: string) => id.trim());
      const channels = [];
    
      for (const channelId of predefinedChannelIdsArray) {
        const params = new URLSearchParams({
          channel: channelId,
        });
    
        const response = await fetch(
          `https://slack.com/api/conversations.info?${params}`,
          { headers: this.botHeaders }
        );
        const data = await response.json();
    
        if (data.ok && data.channel && !data.channel.is_archived) {
          channels.push(data.channel);
        }
      }
    
      return {
        ok: true,
        channels: channels,
        response_metadata: { next_cursor: "" },
      };
    }
  • Input schema for slack_list_channels using Zod: limit (optional number, default 100, max 200) and cursor (optional string for pagination).
    inputSchema: {
      limit: z.number().optional().default(100).describe("Maximum number of channels to return (default 100, max 200)"),
      cursor: z.string().optional().describe("Pagination cursor for next page of results"),
    },

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.0.0
    • addedInput schema / $schema
      Added value: +"http://json-schema.org/draft-07/schema#"
    • addedInput schema / additionalProperties
      Added value: +false
  2. First observed

TDQS

B3.4/5.0
Behavior3/5

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

Discloses that it lists channels the bot is a member of or pre-defined channels, and mentions pagination. However, no annotations exist, and the description does not state side effects, required permissions, or rate limits. As a read operation, it should explicitly note it does not modify state.

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

Conciseness5/5

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

Single sentence, no redundancy, efficiently packs core information: what is listed and pagination support. Front-loaded with verb and resource.

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

Completeness4/5

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

For a simple list tool with 2 parameters and no output schema, the description covers key scope and pagination. Missing details about return fields, but this is not critical given the tool's straightforward nature.

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?

Schema coverage is 100% with clear descriptions for limit and cursor. The description adds 'pre-defined channels' context but does not enhance understanding of parameters beyond what the schema already provides. Baseline of 3 is appropriate.

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?

Clearly states it lists public and private channels with pagination, specifying scope (bot member or pre-defined). Does not explicitly differentiate from siblings but the verb 'list' and resource 'channels' are distinct from other tools like posting messages or getting 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 on when to use this tool versus alternatives. For example, if an agent needs to find a channel by name or get all channels in workspace, this description does not clarify limitations or suggest other tools.

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