discord_get_server_info
Retrieve detailed Discord server data, including channels and member count, by specifying the guild ID using this tool integrated with MCP-Discord for AI-powered Discord interactions.
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)Handler for discord_get_server_info tool. Parses arguments using GetServerInfoSchema, fetches the Discord guild by ID, retrieves all channels, formats server information including name, ID, member count, and channel list, handles login check and errors.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 schema for validating input parameters of discord_get_server_info tool, requiring a guildId string.const GetServerInfoSchema = z.object({ guildId: z.string() });
- src/index.ts:320-330 (registration)Tool registration in the listTools response, defining name, description, and inputSchema matching the handler's expected arguments.{ 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"] } },