slack_list_channels
Retrieve public Slack channels from your workspace with pagination controls to manage large lists efficiently.
Instructions
List public channels in the workspace with pagination
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cursor | No | Pagination cursor for next page of results | |
| limit | No | Maximum number of channels to return (default 100) |
Implementation Reference
- src/index.ts:186-203 (handler)Handler that executes the slack_list_channels tool by parsing arguments, calling Slack's conversations.list API for public channels with pagination support, validating response, and returning JSON-formatted channels list.case 'slack_list_channels': { const args = ListChannelsRequestSchema.parse( request.params.arguments ); const response = await slackClient.conversations.list({ limit: args.limit, cursor: args.cursor, types: 'public_channel', // Only public channels }); if (!response.ok) { throw new Error(`Failed to list channels: ${response.error}`); } const parsed = ListChannelsResponseSchema.parse(response); return { content: [{ type: 'text', text: JSON.stringify(parsed) }], }; }
- src/schemas.ts:184-197 (schema)Zod schema defining the input parameters for slack_list_channels: optional cursor for pagination and limit (default 100, max 1000).export const ListChannelsRequestSchema = z.object({ cursor: z .string() .optional() .describe('Pagination cursor for next page of results'), limit: z .number() .int() .min(1) .max(1000) // Align with Slack API's default limit (conversations.list is actually cursor-based) .optional() .default(100) .describe('Maximum number of channels to return (default 100)'), });
- src/index.ts:116-120 (registration)Registration of the slack_list_channels tool in the MCP server's listTools response, including name, description, and input schema reference.{ name: 'slack_list_channels', description: 'List public channels in the workspace with pagination', inputSchema: zodToJsonSchema(ListChannelsRequestSchema), },
- src/schemas.ts:416-418 (schema)Zod schema for validating the response from Slack's conversations.list API, extending base response with array of ChannelSchema objects.export const ListChannelsResponseSchema = BaseResponseSchema.extend({ channels: z.array(ChannelSchema).optional(), });
- src/schemas.ts:7-33 (schema)Base ChannelSchema used in ListChannelsResponseSchema for typing individual channel objects returned by the tool.export const ChannelSchema = z .object({ conversation_host_id: z.string().optional(), created: z.number().optional(), id: z.string().optional(), is_archived: z.boolean().optional(), name: z.string().optional(), name_normalized: z.string().optional(), num_members: z.number().optional(), purpose: z .object({ creator: z.string().optional(), last_set: z.number().optional(), value: z.string().optional(), }) .optional(), shared_team_ids: z.array(z.string()).optional(), topic: z .object({ creator: z.string().optional(), last_set: z.number().optional(), value: z.string().optional(), }) .optional(), updated: z.number().optional(), }) .strip();