Skip to main content
Glama

discord_get_server_info

Retrieve detailed Discord server information including channels and member count by providing the guild ID.

Instructions

Retrieves detailed information about a Discord server including channels and member count

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYes

Implementation Reference

  • The primary handler function for 'discord_get_server_info' tool. Fetches Discord guild/server details including member count, channel categorization by type, detailed channel list, features, and premium info. Returns formatted JSON response.
    export async function getServerInfoHandler( args: unknown, context: ToolContext ): Promise<ToolResponse> { const { guildId } = GetServerInfoSchema.parse(args); try { if (!context.client.isReady()) { return { content: [{ type: 'text', text: 'Discord client not logged in.' }], isError: true, }; } const guild = await context.client.guilds.fetch(guildId); if (!guild) { return { content: [ { type: 'text', text: `Cannot find guild with ID: ${guildId}` }, ], isError: true, }; } // Fetch additional server data await guild.fetch(); // Fetch channel information const channels = await guild.channels.fetch(); // Categorize channels by type const channelsByType = { text: channels.filter((c) => c?.type === ChannelType.GuildText).size, voice: channels.filter((c) => c?.type === ChannelType.GuildVoice).size, category: channels.filter((c) => c?.type === ChannelType.GuildCategory) .size, forum: channels.filter((c) => c?.type === ChannelType.GuildForum).size, announcement: channels.filter( (c) => c?.type === ChannelType.GuildAnnouncement ).size, stage: channels.filter((c) => c?.type === ChannelType.GuildStageVoice) .size, total: channels.size, }; // Get detailed information for all channels const channelDetails = channels .map((channel) => { if (!channel) { return null; } return { id: channel.id, name: channel.name, type: ChannelType[channel.type] || channel.type, categoryId: channel.parentId, position: channel.position, // Only add topic for text channels topic: 'topic' in channel ? channel.topic : null, }; }) .filter((c) => c !== null); // Filter out null values // Group channels by type const groupedChannels = { text: channelDetails.filter( (c) => c.type === ChannelType[ChannelType.GuildText] || c.type === ChannelType.GuildText ), voice: channelDetails.filter( (c) => c.type === ChannelType[ChannelType.GuildVoice] || c.type === ChannelType.GuildVoice ), category: channelDetails.filter( (c) => c.type === ChannelType[ChannelType.GuildCategory] || c.type === ChannelType.GuildCategory ), forum: channelDetails.filter( (c) => c.type === ChannelType[ChannelType.GuildForum] || c.type === ChannelType.GuildForum ), announcement: channelDetails.filter( (c) => c.type === ChannelType[ChannelType.GuildAnnouncement] || c.type === ChannelType.GuildAnnouncement ), stage: channelDetails.filter( (c) => c.type === ChannelType[ChannelType.GuildStageVoice] || c.type === ChannelType.GuildStageVoice ), all: channelDetails, }; // Get member count const approximateMemberCount = guild.approximateMemberCount || 'unknown'; // Format guild information const guildInfo = { id: guild.id, name: guild.name, description: guild.description, icon: guild.iconURL(), owner: guild.ownerId, createdAt: guild.createdAt, memberCount: approximateMemberCount, channels: { count: channelsByType, details: groupedChannels, }, features: guild.features, premium: { tier: guild.premiumTier, subscriptions: guild.premiumSubscriptionCount, }, }; return { content: [{ type: 'text', text: JSON.stringify(guildInfo, null, 2) }], }; } catch (error) { return handleDiscordError(error); } }
  • MCP tool schema definition including name, description, and input schema requiring 'guildId'.
    { 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'], }, },
  • src/server.ts:156-159 (registration)
    Tool registration in the MCP server request handler switch statement, dispatching to getServerInfoHandler.
    case 'discord_get_server_info': this.logClientState('before discord_get_server_info handler'); toolResponse = await getServerInfoHandler(args, this.toolContext); return toolResponse;
  • Zod schema for input validation used in the handler (GetServerInfoSchema).
    export const GetServerInfoSchema = z.object({ guildId: z.string(), });

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/IQAIcom/mcp-discord'

If you have feedback or need assistance with the MCP directory API, please join our Discord server