Skip to main content
Glama
scarecr0w12

discord-mcp

list_threads

Retrieve all threads within a Discord channel to manage discussions and organize conversations effectively.

Instructions

List all threads in a channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
channelIdYesThe ID of the parent channel
archivedNoInclude archived threads (default false)

Implementation Reference

  • Registration of the 'list_threads' tool, including description, input schema using Zod, and the complete inline handler function that fetches threads from a Discord channel using discord.js.
    server.tool(
      'list_threads',
      'List all threads in a channel',
      {
        guildId: z.string().describe('The ID of the server (guild)'),
        channelId: z.string().describe('The ID of the parent channel'),
        archived: z.boolean().optional().describe('Include archived threads (default false)'),
      },
      async ({ guildId, channelId, archived = false }) => {
        const result = await withErrorHandling(async () => {
          const client = await getDiscordClient();
          const guild = await client.guilds.fetch(guildId);
          const channel = await guild.channels.fetch(channelId);
          
          if (!channel || (channel.type !== ChannelType.GuildText && 
              channel.type !== ChannelType.GuildAnnouncement && 
              channel.type !== ChannelType.GuildForum)) {
            throw new Error('Channel does not support threads');
          }
    
          const threadChannel = channel as TextChannel | NewsChannel | ForumChannel;
          const threads = archived 
            ? await threadChannel.threads.fetchArchived()
            : await threadChannel.threads.fetchActive();
    
          return threads.threads.map((thread) => ({
            id: thread.id,
            name: thread.name,
            type: ChannelType[thread.type],
            parentId: thread.parentId,
            ownerId: thread.ownerId,
            archived: thread.archived,
            locked: thread.locked,
            autoArchiveDuration: thread.autoArchiveDuration,
            messageCount: thread.messageCount,
            memberCount: thread.memberCount,
            createdAt: thread.createdAt?.toISOString(),
            archiveTimestamp: thread.archiveTimestamp ? new Date(thread.archiveTimestamp).toISOString() : null,
          }));
        });
    
        if (!result.success) {
          return { content: [{ type: 'text', text: result.error }], isError: true };
        }
    
        return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
      }
    );
  • The core handler logic for list_threads: fetches guild and channel, validates channel type, fetches active or archived threads, maps to structured data, handles errors with withErrorHandling, and returns JSON stringified response.
    async ({ guildId, channelId, archived = false }) => {
      const result = await withErrorHandling(async () => {
        const client = await getDiscordClient();
        const guild = await client.guilds.fetch(guildId);
        const channel = await guild.channels.fetch(channelId);
        
        if (!channel || (channel.type !== ChannelType.GuildText && 
            channel.type !== ChannelType.GuildAnnouncement && 
            channel.type !== ChannelType.GuildForum)) {
          throw new Error('Channel does not support threads');
        }
    
        const threadChannel = channel as TextChannel | NewsChannel | ForumChannel;
        const threads = archived 
          ? await threadChannel.threads.fetchArchived()
          : await threadChannel.threads.fetchActive();
    
        return threads.threads.map((thread) => ({
          id: thread.id,
          name: thread.name,
          type: ChannelType[thread.type],
          parentId: thread.parentId,
          ownerId: thread.ownerId,
          archived: thread.archived,
          locked: thread.locked,
          autoArchiveDuration: thread.autoArchiveDuration,
          messageCount: thread.messageCount,
          memberCount: thread.memberCount,
          createdAt: thread.createdAt?.toISOString(),
          archiveTimestamp: thread.archiveTimestamp ? new Date(thread.archiveTimestamp).toISOString() : null,
        }));
      });
    
      if (!result.success) {
        return { content: [{ type: 'text', text: result.error }], isError: true };
      }
    
      return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
    }
  • Input schema defined using Zod for parameters: guildId, channelId, and optional archived flag.
    {
      guildId: z.string().describe('The ID of the server (guild)'),
      channelId: z.string().describe('The ID of the parent channel'),
      archived: z.boolean().optional().describe('Include archived threads (default false)'),
    },
  • src/index.ts:64-64 (registration)
    Invocation of registerThreadTools(server) in the MCP server creation, which registers the list_threads tool among other thread management tools.
    registerThreadTools(server);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('List all threads') but doesn't explain key behaviors such as pagination, rate limits, authentication requirements, or what 'archived' threads entail. This is inadequate for a tool with potential complexity.

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, efficient sentence with zero waste. It's front-loaded with the core action and resource, making it easy to parse quickly without unnecessary elaboration.

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

Completeness2/5

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

Given no annotations, no output schema, and a list operation with potential behavioral nuances (e.g., archived threads), the description is incomplete. It lacks details on return format, error handling, or operational constraints, making it insufficient for reliable agent 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?

Schema description coverage is 100%, so the schema already documents all parameters (guildId, channelId, archived). The description adds no additional meaning beyond implying a channel context, which aligns with the schema but doesn't enhance understanding. Baseline 3 is appropriate when schema does the heavy lifting.

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 threads in a channel'), making the purpose specific and understandable. However, it doesn't differentiate from sibling tools like 'list_channels' or 'get_channel_info' that might also involve thread-related operations, which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any prerequisites, exclusions, or sibling tools like 'create_thread' or 'delete_thread' that might be relevant in different contexts, leaving the agent with insufficient usage context.

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/scarecr0w12/discord-mcp'

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