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"),
    },
Behavior2/5

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

With no annotations provided, the description must fully disclose behavior. It mentions pagination and the scope (bot's membership) but does not explicitly state it is a read-only operation, nor does it address auth requirements or rate limits. The term 'pre-defined' is vague.

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?

A single, well-structured sentence that front-loads the main action and scope. Every word earns its place with no fluff.

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?

Given the simplicity of the tool (2 params, no output schema, no nested objects), the description is largely complete. It covers what is listed and pagination, but could be slightly more explicit about the 'pre-defined' channels concept.

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 both parameters described. The description adds 'pagination' context but does not enhance understanding beyond the schema. Baseline score of 3 is appropriate as no additional semantic value is provided.

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

Purpose5/5

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

The description clearly states the verb 'list' and the resource 'channels', specifying scope as public/private channels the bot is a member of or pre-defined channels, with pagination. This distinguishes it from sibling tools like slack_add_reaction or slack_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?

There is no explicit guidance on when to use this tool versus alternatives. No exclusions or context about when not to use it are provided, leaving the agent to infer usage from the description alone.

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