Skip to main content
Glama

list_channels

Retrieve available channels in a Slack workspace, with options to filter by channel type, exclude archived channels, and limit results.

Instructions

List channels in the Slack workspace

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typesNoComma-separated list of channel types (public_channel, private_channel, mpim, im)public_channel,private_channel
exclude_archivedNoExclude archived channels
limitNoMaximum number of channels to return

Implementation Reference

  • The main handler function that implements the 'list_channels' tool logic. It validates input with Zod schema and calls Slack's conversations.list API, returning channels and pagination cursor.
    export async function listChannels(client: SlackClientWrapper, args: unknown) {
      const params = listChannelsSchema.parse(args);
    
      return await client.safeCall(async () => {
        const result = await client.getClient().conversations.list({
          types: params.types,
          exclude_archived: params.exclude_archived,
          limit: params.limit,
          cursor: params.cursor,
        });
    
        return {
          channels: result.channels || [],
          next_cursor: result.response_metadata?.next_cursor,
        };
      });
    }
  • Zod schema used for input validation in the listChannels handler.
    export const listChannelsSchema = z.object({
      types: z.string().optional().default('public_channel,private_channel'),
      exclude_archived: z.boolean().optional().default(true),
      limit: z.number().min(1).max(1000).optional().default(100),
      cursor: z.string().optional(),
    });
  • src/index.ts:47-72 (registration)
    Tool definition registration in the list_tools response, including name, description, and input schema.
    {
      name: 'list_channels',
      description: 'List channels in the Slack workspace',
      inputSchema: {
        type: 'object',
        properties: {
          types: {
            type: 'string',
            description: 'Comma-separated list of channel types (public_channel, private_channel, mpim, im)',
            default: 'public_channel,private_channel',
          },
          exclude_archived: {
            type: 'boolean',
            description: 'Exclude archived channels',
            default: true,
          },
          limit: {
            type: 'number',
            description: 'Maximum number of channels to return',
            default: 100,
            minimum: 1,
            maximum: 1000,
          },
        },
      },
    },
  • src/index.ts:415-415 (registration)
    Handler registration in the toolHandlers map for the call_tool request, linking 'list_channels' to the imported listChannels function.
    list_channels: (args) => channelTools.listChannels(slackClient, args),

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/Hais/slack-bot-mcp'

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