Skip to main content
Glama
jar285

MCP-Discord

by jar285

discord_list_guilds

Retrieve all Discord servers accessible to the bot, enabling server management and overview within the MCP-Discord platform.

Instructions

Lists all Discord servers (guilds) the bot has access to

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function for the 'discord_list_guilds' tool that lists all Discord guilds (servers) the bot has access to, including their IDs, names, member counts, and channels.
    case "discord_list_guilds": {
      ListGuildsSchema.parse(args);
      
      try {
        if (!client.isReady()) {
          return {
            content: [{ type: "text", text: "Discord client not logged in. Please use discord_login tool first." }],
            isError: true
          };
        }
        
        // Get all guilds the bot is in
        const guilds = client.guilds.cache.map(guild => ({
          id: guild.id,
          name: guild.name,
          memberCount: guild.memberCount,
          channels: guild.channels.cache.map(channel => ({
            id: channel.id,
            name: channel.name,
            type: channel.type
          }))
        }));
        
        if (guilds.length === 0) {
          return {
            content: [{ type: "text", text: "The bot is not a member of any Discord servers." }]
          };
        }
        
        return {
          content: [{ 
            type: "text", 
            text: `Available Discord Servers:\n${JSON.stringify(guilds, null, 2)}` 
          }]
        };
      } catch (error) {
        return {
          content: [{ type: "text", text: `Failed to list guilds: ${error}` }],
          isError: true
        };
      }
    }
  • Zod schema for input validation of the 'discord_list_guilds' tool, which requires no parameters.
    const ListGuildsSchema = z.object({});
  • src/index.ts:206-213 (registration)
    Tool registration in the listTools response, defining name, description, and input schema for 'discord_list_guilds'.
    {
      name: "discord_list_guilds",
      description: "Lists all Discord servers (guilds) the bot has access to",
      inputSchema: {
        type: "object",
        properties: {},
        required: []
      }

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