discord_list_guilds
Retrieve a list of all Discord servers the bot is authorized to access, enabling efficient server management and monitoring within the MCP-Discord ecosystem.
Instructions
Lists all Discord servers (guilds) the bot has access to
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:506-547 (handler)Handler for the discord_list_guilds tool. Validates input with ListGuildsSchema, checks if Discord client is ready, fetches guilds from client.guilds.cache, maps guild details including channels, and returns formatted JSON string of available guilds.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 }; } }
- src/index.ts:206-214 (registration)Tool registration in the ListToolsRequestHandler, defining name, description, and empty input schema matching ListGuildsSchema.{ name: "discord_list_guilds", description: "Lists all Discord servers (guilds) the bot has access to", inputSchema: { type: "object", properties: {}, required: [] } },
- src/index.ts:85-85 (schema)Zod schema for input validation of discord_list_guilds tool, defining an empty object schema.const ListGuildsSchema = z.object({});