Skip to main content
Glama
scarecr0w12

discord-mcp

list_channels

Retrieve all channels in a Discord server by providing the server ID to manage and organize your community spaces.

Instructions

List all channels in a Discord server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)

Implementation Reference

  • The handler function that executes the tool logic: fetches Discord client, retrieves guild by ID, fetches all channels, maps to structured data (id, name, type, parentId, position), filters valid channels, handles errors with withErrorHandling, and returns JSON-formatted response.
    async ({ guildId }) => {
      const result = await withErrorHandling(async () => {
        const client = await getDiscordClient();
        const guild = await client.guilds.fetch(guildId);
        const channels = await guild.channels.fetch();
    
        return channels.map((ch) => ({
          id: ch?.id,
          name: ch?.name,
          type: ch?.type,
          typeName: ChannelType[ch?.type ?? 0],
          parentId: (ch as GuildChannel)?.parentId,
          position: (ch as GuildChannel)?.position,
        })).filter((ch) => ch.id);
      });
    
      if (!result.success) {
        return { content: [{ type: 'text', text: result.error }], isError: true };
      }
    
      return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
    }
  • Zod input schema defining the required 'guildId' parameter as a string.
      guildId: z.string().describe('The ID of the server (guild)'),
    },
  • Tool registration using McpServer.tool() method, specifying name 'list_channels', description, input schema, and inline handler function.
      'list_channels',
      'List all channels in a Discord server',
      {
        guildId: z.string().describe('The ID of the server (guild)'),
      },
      async ({ guildId }) => {
        const result = await withErrorHandling(async () => {
          const client = await getDiscordClient();
          const guild = await client.guilds.fetch(guildId);
          const channels = await guild.channels.fetch();
    
          return channels.map((ch) => ({
            id: ch?.id,
            name: ch?.name,
            type: ch?.type,
            typeName: ChannelType[ch?.type ?? 0],
            parentId: (ch as GuildChannel)?.parentId,
            position: (ch as GuildChannel)?.position,
          })).filter((ch) => ch.id);
        });
    
        if (!result.success) {
          return { content: [{ type: 'text', text: result.error }], isError: true };
        }
    
        return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
      }
    );
  • src/index.ts:55-55 (registration)
    Call to registerChannelTools function which registers the list_channels tool (and other channel tools) on the MCP server instance.
    registerChannelTools(server);
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states it's a list operation, implying read-only behavior, but doesn't disclose critical details like pagination, rate limits, authentication requirements, or what data is returned (e.g., channel types, names, IDs). For a tool with zero annotation coverage, this leaves significant behavioral 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 a single, front-loaded sentence with zero wasted words. It directly states the tool's purpose without unnecessary elaboration, making it highly efficient and easy to parse. Every word earns its place.

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 low complexity (single parameter, read-only list operation) and 100% schema coverage, the description is minimally adequate. However, with no annotations and no output schema, it lacks details on behavioral traits (e.g., pagination, auth) and return values, leaving gaps that could hinder effective use by an agent.

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%, with the single parameter 'guildId' clearly documented in the schema. The description doesn't add any parameter-specific information beyond implying the need for a server context. This meets the baseline of 3 when the schema adequately covers parameters, though no extra value is added.

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 ('List all channels') and the resource ('in a Discord server'), making the purpose immediately understandable. It distinguishes from siblings like 'get_channel_info' (single channel) and 'create_channel' (write operation), though it doesn't explicitly contrast with them. The verb+resource combination is specific but could be more precise about scope.

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 prerequisites (e.g., needing server access), contrast with similar tools like 'list_threads' or 'get_channel_info', or specify use cases. Without any contextual cues, the agent must infer usage from the name alone.

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