Skip to main content
Glama
ubie-oss

Slack MCP Server

by ubie-oss

slack_search_channels

Find Slack channels by searching for keywords in their names, including archived channels if needed, with configurable result limits.

Instructions

Search for channels by partial name match. Use this when you need to find channels containing specific keywords in their names. Returns up to the specified limit of matching channels.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch channels by partial name match (case-insensitive). Searches across channel names.
limitNoMaximum number of channels to return (default 20)
include_archivedNoInclude archived channels in results (default false)

Implementation Reference

  • The handler function for the 'slack_search_channels' tool. It parses the input arguments, fetches public channels (optionally excluding archived) using paginated Slack API calls (conversations.list), filters channels client-side by partial name match (case-insensitive), limits the results, and returns the response parsed with ListChannelsResponseSchema.
    case 'slack_search_channels': {
      const args = SearchChannelsRequestSchema.parse(
        request.params.arguments
      );
    
      // Fetch all channels with a reasonable limit
      const allChannels: Array<{
        id?: string;
        name?: string;
        is_archived?: boolean;
        [key: string]: unknown;
      }> = [];
      let cursor: string | undefined;
      const maxPages = 5; // Limit to prevent infinite loops
      let pageCount = 0;
    
      // Fetch multiple pages if needed
      while (pageCount < maxPages) {
        const response = await slackClient.conversations.list({
          types: 'public_channel',
          exclude_archived: !args.include_archived,
          limit: 1000, // Max allowed by Slack API
          cursor,
        });
    
        if (!response.ok) {
          throw new Error(`Failed to search channels: ${response.error}`);
        }
    
        if (response.channels) {
          allChannels.push(...(response.channels as typeof allChannels));
        }
    
        cursor = response.response_metadata?.next_cursor;
        pageCount++;
    
        // Stop if no more pages
        if (!cursor) break;
      }
    
      // Filter channels by name (case-insensitive partial match)
      const searchTerm = args.query.toLowerCase();
      const filteredChannels = allChannels.filter((channel) =>
        channel.name?.toLowerCase().includes(searchTerm)
      );
    
      // Limit results
      const limitedChannels = filteredChannels.slice(0, args.limit);
    
      const response = {
        ok: true,
        channels: limitedChannels,
      };
    
      const parsed = ListChannelsResponseSchema.parse(response);
      return {
        content: [{ type: 'text', text: JSON.stringify(parsed) }],
      };
    }
  • Zod schema defining the input parameters for the 'slack_search_channels' tool: query (string), limit (number, default 20, max 100), include_archived (boolean, default false).
    export const SearchChannelsRequestSchema = z.object({
      query: z
        .string()
        .describe(
          'Search channels by partial name match (case-insensitive). Searches across channel names.'
        ),
      limit: z
        .number()
        .int()
        .min(1)
        .max(100)
        .optional()
        .default(20)
        .describe('Maximum number of channels to return (default 20)'),
      include_archived: z
        .boolean()
        .optional()
        .default(false)
        .describe('Include archived channels in results (default false)'),
    });
  • src/index.ts:164-169 (registration)
    Registration of the 'slack_search_channels' tool in the listTools response, specifying name, description, and input schema.
    {
      name: 'slack_search_channels',
      description:
        'Search for channels by partial name match. Use this when you need to find channels containing specific keywords in their names. Returns up to the specified limit of matching channels.',
      inputSchema: zodToJsonSchema(SearchChannelsRequestSchema),
    },

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/ubie-oss/slack-mcp-server'

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