Skip to main content
Glama
jar285

MCP-Discord

by jar285

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

Implementation Reference

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

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