Skip to main content
Glama
jar285

MCP-Discord

by jar285

discord_get_forum_channels

Retrieve all forum channels from a Discord server to manage discussions and organize community conversations efficiently.

Instructions

Lists all forum channels in a specified Discord server (guild)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYes

Implementation Reference

  • Main execution logic for the discord_get_forum_channels tool. Parses input, checks client readiness, fetches guild and channels, filters for forum channels (ChannelType.GuildForum), formats and returns channel info (id, name, topic).
    case "discord_get_forum_channels": {
      const { guildId } = GetForumChannelsSchema.parse(args);
      try {
        if (!client.isReady()) {
          return {
            content: [{ type: "text", text: "Discord client not logged in. Please use discord_login tool first." }],
            isError: true
          };
        }
    
        const guild = await client.guilds.fetch(guildId);
        if (!guild) {
          return {
            content: [{ type: "text", text: `Cannot find guild with ID: ${guildId}` }],
            isError: true
          };
        }
    
        // Fetch all channels from the guild
        const channels = await guild.channels.fetch();
        
        // Filter to get only forum channels
        const forumChannels = channels.filter(channel => channel?.type === ChannelType.GuildForum);
        
        if (forumChannels.size === 0) {
          return {
            content: [{ type: "text", text: `No forum channels found in guild: ${guild.name}` }]
          };
        }
    
        // Format forum channels information
        const forumInfo = forumChannels.map(channel => ({
          id: channel.id,
          name: channel.name,
          topic: channel.topic || "No topic set"
        }));
    
        return {
          content: [{ type: "text", text: JSON.stringify(forumInfo, null, 2) }]
        };
      } catch (error) {
        return {
          content: [{ type: "text", text: `Failed to fetch forum channels: ${error}` }],
          isError: true
        };
      }
    }
  • Zod input schema definition requiring guildId string, used for validation in handler and reflected in tool registration.
    const GetForumChannelsSchema = z.object({
        guildId: z.string()
    });
  • src/index.ts:227-237 (registration)
    Tool registration entry in ListToolsRequestSchema handler, defining name, description, and inputSchema matching the Zod schema.
    {
      name: "discord_get_forum_channels",
      description: "Lists all forum channels in a specified Discord server (guild)",
      inputSchema: {
        type: "object",
        properties: {
          guildId: { type: "string" }
        },
        required: ["guildId"]
      }
    },

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

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