Skip to main content
Glama
oregpt

Slack MCP Server

by oregpt

channels_list

Retrieve and organize Slack workspace channels by type (public, private, DMs) with optional popularity sorting and pagination for efficient channel discovery.

Instructions

Lists workspace channels by type (public, private, DMs, group DMs) with optional popularity sorting. Supports pagination.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accessTokenYesSlack OAuth token (xoxp-... or xoxb-...)
channel_typesYesComma-separated channel types: mpim, im, public_channel, private_channel
sortNoSort by member count (popularity)
limitNoNumber of results (max: 999, default: 100)
cursorNoPagination cursor from previous response

Implementation Reference

  • The handler function for the 'channels_list' tool. It validates input using ChannelsListSchema, calls Slack's conversations.list API filtered by channel types, optionally sorts channels by member count (popularity), formats the response, and handles errors.
    /**
     * Tool: channels_list
     * Lists workspace channels with optional sorting
     */
    export async function channelsList(args: any): Promise<ToolResponse> {
      try {
        const validated = ChannelsListSchema.parse(args);
        const client = new WebClient(validated.accessToken);
    
        console.log('Listing channels of types:', validated.channel_types);
    
        // Fetch channels
        const result = await client.conversations.list({
          types: validated.channel_types,
          limit: validated.limit || 100,
          cursor: validated.cursor
        });
    
        let channels = result.channels || [];
    
        // Sort by popularity (member count) if requested
        if (validated.sort === 'popularity') {
          channels = channels.sort((a: any, b: any) => {
            const aCount = a.num_members || 0;
            const bCount = b.num_members || 0;
            return bCount - aCount;
          });
        }
    
        return {
          success: true,
          data: {
            channels: channels.map((ch: any) => ({
              id: ch.id,
              name: ch.name,
              topic: ch.topic?.value,
              purpose: ch.purpose?.value,
              member_count: ch.num_members,
              is_private: ch.is_private,
              is_channel: ch.is_channel,
              is_im: ch.is_im,
              is_mpim: ch.is_mpim
            })),
            has_more: Boolean(result.response_metadata?.next_cursor),
            cursor: result.response_metadata?.next_cursor
          }
        };
      } catch (error: any) {
        if (error.name === 'ZodError') {
          return { success: false, error: `Validation error: ${error.errors.map((e: any) => e.message).join(', ')}` };
        }
        return handleSlackError(error);
      }
    }
  • Zod input schema for the channels_list tool, defining required accessToken and channel_types, with optional sort, limit, and cursor parameters.
    /**
     * Schema for channels_list tool
     * Lists workspace channels with optional sorting
     */
    export const ChannelsListSchema = z.object({
      accessToken: z.string().describe("Slack OAuth token (xoxp-... or xoxb-...)"),
      channel_types: z.string().describe("Comma-separated channel types: mpim, im, public_channel, private_channel"),
      sort: z.enum(['popularity']).optional().describe("Sort by member count (popularity)"),
      limit: z.number().optional().describe("Number of results (max: 999, default: 100)"),
      cursor: z.string().optional().describe("Pagination cursor from previous response")
    });
  • src/index.ts:110-114 (registration)
    Registration of the channels_list tool in the MCP server's listTools handler, including name, description, and input schema converted from Zod.
    {
      name: 'channels_list',
      description: 'Lists workspace channels by type (public, private, DMs, group DMs) with optional popularity sorting. Supports pagination.',
      inputSchema: zodToMCPSchema(ChannelsListSchema)
    }
  • src/index.ts:141-143 (registration)
    Dispatch handler in the MCP server's callToolRequest that routes calls to the channels_list tool to the channelsList function.
    case 'channels_list':
      result = await channelsList(args);
      break;
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions pagination and sorting, which are useful behavioral traits, but does not cover critical aspects like authentication requirements (implied by accessToken but not explained), rate limits, error handling, or what the output looks like. It adds some context but leaves significant gaps for a tool with multiple parameters and no output schema.

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?

The description is a single, well-structured sentence that efficiently covers the tool's purpose, types, and key features (sorting, pagination) without unnecessary words. It is front-loaded with the main action and resource, making it easy to scan and understand quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (5 parameters, no annotations, no output schema), the description is incomplete. It covers the basic purpose and some features but lacks details on authentication, error handling, output format, and explicit differentiation from siblings. While concise, it does not fully compensate for the missing structured data, leaving the agent with insufficient context for optimal use.

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?

The schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema by mentioning 'popularity sorting' (implied by the sort parameter) and 'pagination' (implied by cursor), but does not provide additional syntax, format details, or usage examples. This meets the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the action ('Lists') and resource ('workspace channels'), specifying the types (public, private, DMs, group DMs) and optional features (popularity sorting, pagination). However, it does not explicitly differentiate from sibling tools like conversations_history or conversations_replies, which focus on message retrieval rather than channel listing, leaving some ambiguity in tool selection.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for listing channels with type filtering and sorting, but provides no explicit guidance on when to use this tool versus alternatives like conversations_history for message access. It mentions 'optional popularity sorting' and 'pagination' as features, which hints at context but lacks clear when/when-not instructions or named alternatives.

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/oregpt/Agenticledger_MCP_Slack'

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