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
| Name | Required | Description | Default |
|---|---|---|---|
| types | No | Comma-separated list of channel types (public_channel, private_channel, mpim, im) | public_channel,private_channel |
| exclude_archived | No | Exclude archived channels | |
| limit | No | Maximum number of channels to return |
Implementation Reference
- src/tools/channels.ts:9-25 (handler)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, }; }); }
- src/utils/validators.ts:11-16 (schema)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),