Skip to main content
Glama
zencoderai

Slack

by zencoderai

slack_list_channels

Retrieve a list of public and private Slack channels accessible to the bot, with pagination support for large workspaces.

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

  • index.ts:63-109 (handler)
    Core handler logic for listing Slack channels. Supports fetching via Slack API conversations.list with pagination or using predefined channel IDs from environment variable by calling conversations.info for each.
    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: "" }, }; }
  • Zod-based input schema defining optional 'limit' and 'cursor' parameters for the tool.
    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"), },
  • index.ts:230-246 (registration)
    Registration of the 'slack_list_channels' tool in the MCP server using registerTool, including title, description, input schema, and thin wrapper handler that delegates to SlackClient.getChannels.
    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) }], }; } );

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