Skip to main content
Glama
jar285

MCP-Discord

by jar285

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
NameRequiredDescriptionDefault
guildIdYes

Implementation Reference

  • 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 }; } }
  • 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"] } },

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