discord_get_server_info
Retrieve Discord server details like channels and member count by providing the guild ID to analyze server structure and activity.
Instructions
Retrieves detailed information about a Discord server including channels and member count
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes |
Implementation Reference
- src/index.ts:930-983 (handler)The main handler logic for the discord_get_server_info tool. It validates input with GetServerInfoSchema, fetches the Discord guild using client.guilds.fetch, retrieves all channels, formats the server info (name, ID, member count, channels), and returns it as text content.case "discord_get_server_info": { // Use default server ID if not provided let parsedArgs = GetServerInfoSchema.parse(args); if (parsedArgs.guildId === 'default') { parsedArgs.guildId = process.env.DEFAULT_SERVER_ID || ''; } const { guildId } = parsedArgs; 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 channels const channels = await guild.channels.fetch(); // Format channel info const channelInfo = channels.map(channel => { return { id: channel?.id, name: channel?.name, type: channel?.type }; }); return { content: [{ type: "text", text: `Server Information:\n` + `Name: ${guild.name}\n` + `ID: ${guild.id}\n` + `Member Count: ${guild.memberCount}\n` + `Channels: ${JSON.stringify(channelInfo, null, 2)}` }] }; } catch (error) { return { content: [{ type: "text", text: `Get server info failed: ${error}` }], isError: true }; } }
- src/index.ts:87-89 (schema)Zod input schema definition used for validating the tool arguments: requires a guildId string.const GetServerInfoSchema = z.object({ guildId: z.string() });
- src/index.ts:321-330 (registration)Tool registration in the ListTools response array. Defines the tool's name, description, and JSON input schema matching the Zod schema.name: "discord_get_server_info", description: "Retrieves detailed information about a Discord server including channels and member count", inputSchema: { type: "object", properties: { guildId: { type: "string" } }, required: ["guildId"] } },