Skip to main content
Glama
discourse

Discourse MCP

Official
by discourse

List Chat Channels

discourse_list_chat_channels

Retrieve public chat channels from Discourse forums with filtering options for name, status, and pagination to manage channel discovery.

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

  • Handler function that fetches and formats Discourse chat channels list using the site API client, supports filtering, pagination, and error handling.
    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 input schema defining optional parameters for filtering and paginating chat channels.
    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 server, including metadata and handler reference.
    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
          };
        }
      }
    );
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 mentions that the tool returns 'channel information including title, description, and member counts', which provides some output context. However, it doesn't address important behavioral aspects like pagination behavior (implied by offset/limit parameters but not explained), rate limits, authentication requirements, or whether this is a read-only operation. For a listing 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 purpose and scope, while the second describes the return format. There's zero wasted language, and the most important information (what the tool does) is front-loaded.

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?

For a listing tool with comprehensive parameter documentation (100% schema coverage) but no annotations and no output schema, the description provides adequate but incomplete context. It covers the basic purpose and return format, but lacks behavioral details that would be important for an AI agent. The absence of output schema means the description should ideally provide more detail about the return structure, but it only mentions three fields without specifying format or completeness.

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?

Schema description coverage is 100%, so the schema already fully documents all 4 parameters. The description adds no parameter-specific information beyond what's in the schema. According to scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description. The description doesn't compensate with additional parameter context, but doesn't need to given the comprehensive schema.

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 verb 'List' and resource 'all public chat channels visible to the current user', making the purpose immediately understandable. It distinguishes from siblings like 'discourse_list_user_chat_channels' by specifying 'public' channels rather than user-specific ones. However, it doesn't explicitly contrast with other listing tools like 'discourse_list_categories' or 'discourse_list_tags'.

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 retrieving public chat channels, but provides no explicit guidance on when to use this versus alternatives like 'discourse_list_user_chat_channels' or 'discourse_search'. It mentions 'visible to the current user' which provides some context about access permissions, but lacks clear when/when-not scenarios 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/discourse/discourse-mcp'

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