Skip to main content
Glama
scarecr0w12

discord-mcp

get_server_info

Retrieve detailed information about a Discord server by providing its guild ID. This tool helps users access server data for management and analysis purposes.

Instructions

Get detailed information about a specific Discord server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)

Implementation Reference

  • The core handler function that executes the get_server_info tool logic: fetches the Discord guild by ID, gathers detailed info including channels and roles, handles errors with withErrorHandling, and returns JSON-formatted response.
    async ({ guildId }) => {
      const result = await withErrorHandling(async () => {
        const client = await getDiscordClient();
        const guild = await client.guilds.fetch(guildId);
    
        // Fetch additional data
        const channels = guild.channels.cache;
        const roles = guild.roles.cache;
    
        return {
          id: guild.id,
          name: guild.name,
          description: guild.description,
          memberCount: guild.memberCount,
          ownerId: guild.ownerId,
          createdAt: guild.createdAt.toISOString(),
          icon: guild.iconURL(),
          banner: guild.bannerURL(),
          verificationLevel: guild.verificationLevel,
          premiumTier: guild.premiumTier,
          premiumSubscriptionCount: guild.premiumSubscriptionCount,
          preferredLocale: guild.preferredLocale,
          systemChannelId: guild.systemChannelId,
          rulesChannelId: guild.rulesChannelId,
          afkChannelId: guild.afkChannelId,
          afkTimeout: guild.afkTimeout,
          features: guild.features,
          channelCount: channels.size,
          roleCount: roles.size,
          channels: channels.map((ch) => ({
            id: ch.id,
            name: ch.name,
            type: ch.type,
          })),
          roles: roles.map((role) => ({
            id: role.id,
            name: role.name,
            color: role.hexColor,
            position: role.position,
          })),
        };
      });
    
      if (!result.success) {
        return { content: [{ type: 'text', text: result.error }], isError: true };
      }
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result.data, null, 2),
          },
        ],
      };
    }
  • Zod input schema defining the required 'guildId' parameter as a string.
    {
      guildId: z.string().describe('The ID of the server (guild)'),
    },
  • MCP server.tool registration for 'get_server_info' including description, input schema, and inline handler function.
    server.tool(
      'get_server_info',
      'Get detailed information about a specific Discord server',
      {
        guildId: z.string().describe('The ID of the server (guild)'),
      },
      async ({ guildId }) => {
        const result = await withErrorHandling(async () => {
          const client = await getDiscordClient();
          const guild = await client.guilds.fetch(guildId);
    
          // Fetch additional data
          const channels = guild.channels.cache;
          const roles = guild.roles.cache;
    
          return {
            id: guild.id,
            name: guild.name,
            description: guild.description,
            memberCount: guild.memberCount,
            ownerId: guild.ownerId,
            createdAt: guild.createdAt.toISOString(),
            icon: guild.iconURL(),
            banner: guild.bannerURL(),
            verificationLevel: guild.verificationLevel,
            premiumTier: guild.premiumTier,
            premiumSubscriptionCount: guild.premiumSubscriptionCount,
            preferredLocale: guild.preferredLocale,
            systemChannelId: guild.systemChannelId,
            rulesChannelId: guild.rulesChannelId,
            afkChannelId: guild.afkChannelId,
            afkTimeout: guild.afkTimeout,
            features: guild.features,
            channelCount: channels.size,
            roleCount: roles.size,
            channels: channels.map((ch) => ({
              id: ch.id,
              name: ch.name,
              type: ch.type,
            })),
            roles: roles.map((role) => ({
              id: role.id,
              name: role.name,
              color: role.hexColor,
              position: role.position,
            })),
          };
        });
    
        if (!result.success) {
          return { content: [{ type: 'text', text: result.error }], isError: true };
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(result.data, null, 2),
            },
          ],
        };
      }
    );
  • src/index.ts:54-54 (registration)
    Call to registerServerTools which includes the get_server_info tool registration in the main MCP server setup.
    registerServerTools(server);

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

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