Skip to main content
Glama

List Chat Channels

discourse_list_chat_channels

List public chat channels with details like title, description, and member counts. Filter by name, status, or use pagination to browse available channels.

Instructions

List all public chat channels visible to the current user. Returns channel information including title, description, and member counts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNoFilter channels by name/slug
limitNoNumber of channels to return (default: 25, max: 100)
offsetNoPagination offset (default: 0)
statusNoFilter by channel status (e.g., 'open', 'closed', 'archived')

Implementation Reference

  • The handler function that implements the core logic of the 'discourse_list_chat_channels' tool. It fetches chat channels from the Discourse chat API using the provided filters, formats them into a structured markdown response including channel details, pagination info, and handles errors.
    async ({ filter, limit = 25, offset = 0, status }, _extra: any) => {
      try {
        const { base, client } = ctx.siteState.ensureSelectedSite();
    
        // Build query parameters
        const params = new URLSearchParams();
        if (filter) params.append("filter", filter);
        params.append("limit", String(limit));
        params.append("offset", String(offset));
        if (status) params.append("status", status);
    
        const url = `/chat/api/channels?${params.toString()}`;
        const data = (await client.get(url)) as any;
    
        const channels: any[] = data?.channels || [];
    
        if (channels.length === 0) {
          return { content: [{ type: "text", text: "No chat channels found." }] };
        }
    
        const lines: string[] = [];
        lines.push(`# Chat Channels (${channels.length} shown)`);
        lines.push("");
    
        for (const channel of channels) {
          const title = channel.title || `Channel ${channel.id}`;
          const slug = channel.slug || String(channel.id);
          const description = channel.description || "";
          const membersCount = channel.memberships_count || 0;
          const statusText = channel.status || "open";
    
          lines.push(`## ${title}`);
          lines.push(`- **ID**: ${channel.id}`);
          lines.push(`- **Slug**: ${slug}`);
          lines.push(`- **Status**: ${statusText}`);
          lines.push(`- **Members**: ${membersCount}`);
          if (description) {
            lines.push(`- **Description**: ${description}`);
          }
          lines.push(`- **URL**: ${base}/chat/c/${slug}/${channel.id}`);
          lines.push("");
        }
    
        // Add pagination info
        if (data?.meta?.load_more_url) {
          lines.push(`_More channels available. Use offset=${offset + limit} to load next page._`);
        }
    
        return { content: [{ type: "text", text: lines.join("\n") }] };
      } catch (e: any) {
        return {
          content: [{ type: "text", text: `Failed to list chat channels: ${e?.message || String(e)}` }],
          isError: true
        };
      }
  • Zod schema defining the input parameters for the discourse_list_chat_channels tool, including optional filter, limit, offset, and status.
    const schema = z.object({
      filter: z.string().optional().describe("Filter channels by name/slug"),
      limit: z.number().int().min(1).max(100).optional().describe("Number of channels to return (default: 25, max: 100)"),
      offset: z.number().int().min(0).optional().describe("Pagination offset (default: 0)"),
      status: z.string().optional().describe("Filter by channel status (e.g., 'open', 'closed', 'archived')"),
    }).strict();
  • Registers the 'discourse_list_chat_channels' tool with the MCP server, specifying name, title, description, input schema, and handler function.
    server.registerTool(
      "discourse_list_chat_channels",
      {
        title: "List Chat Channels",
        description: "List all public chat channels visible to the current user. Returns channel information including title, description, and member counts.",
        inputSchema: schema.shape,
      },
      async ({ filter, limit = 25, offset = 0, status }, _extra: any) => {
        try {
          const { base, client } = ctx.siteState.ensureSelectedSite();
    
          // Build query parameters
          const params = new URLSearchParams();
          if (filter) params.append("filter", filter);
          params.append("limit", String(limit));
          params.append("offset", String(offset));
          if (status) params.append("status", status);
    
          const url = `/chat/api/channels?${params.toString()}`;
          const data = (await client.get(url)) as any;
    
          const channels: any[] = data?.channels || [];
    
          if (channels.length === 0) {
            return { content: [{ type: "text", text: "No chat channels found." }] };
          }
    
          const lines: string[] = [];
          lines.push(`# Chat Channels (${channels.length} shown)`);
          lines.push("");
    
          for (const channel of channels) {
            const title = channel.title || `Channel ${channel.id}`;
            const slug = channel.slug || String(channel.id);
            const description = channel.description || "";
            const membersCount = channel.memberships_count || 0;
            const statusText = channel.status || "open";
    
            lines.push(`## ${title}`);
            lines.push(`- **ID**: ${channel.id}`);
            lines.push(`- **Slug**: ${slug}`);
            lines.push(`- **Status**: ${statusText}`);
            lines.push(`- **Members**: ${membersCount}`);
            if (description) {
              lines.push(`- **Description**: ${description}`);
            }
            lines.push(`- **URL**: ${base}/chat/c/${slug}/${channel.id}`);
            lines.push("");
          }
    
          // Add pagination info
          if (data?.meta?.load_more_url) {
            lines.push(`_More channels available. Use offset=${offset + limit} to load next page._`);
          }
    
          return { content: [{ type: "text", text: lines.join("\n") }] };
        } catch (e: any) {
          return {
            content: [{ type: "text", text: `Failed to list chat channels: ${e?.message || String(e)}` }],
            isError: true
          };
        }
      }
    );
  • Calls the registerListChatChannels function as part of registering all builtin tools in the MCP server registry.
    registerListChatChannels(server, ctx, { allowWrites: false });
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool returns channel information but doesn't mention important behavioral aspects like whether this is a read-only operation, potential rate limits, authentication requirements, pagination behavior beyond parameters, or what happens when no channels match filters. For a list tool with zero annotation coverage, this leaves significant gaps.

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 perfectly concise with two sentences that each earn their place. The first sentence states the core purpose and scope, while the second sentence clarifies what information is returned. There's zero waste or redundancy in the phrasing.

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 tool's moderate complexity (4 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose and return information but lacks behavioral context that would be important for an agent to use this tool effectively. Without annotations or output schema, the description should do more to explain the operation's characteristics and expected results.

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 has 100% description coverage, so the baseline is 3 even though the tool description doesn't mention any parameters. The description doesn't add parameter-specific context beyond what's already documented in the schema, but the schema adequately covers all 4 parameters with clear descriptions.

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

Purpose5/5

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

The description clearly states the specific action ('List all public chat channels'), the resource ('chat channels'), and scope ('visible to the current user'). It distinguishes from sibling tools like 'discourse_list_user_chat_channels' by specifying 'public' channels rather than user-specific ones, providing clear differentiation.

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 context by stating 'visible to the current user' and 'public chat channels', but doesn't explicitly guide when to use this tool versus alternatives like 'discourse_list_user_chat_channels' or 'discourse_search'. It provides basic context but lacks explicit when/when-not guidance 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/SamSaffron/discourse-mcp'

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