Skip to main content
Glama

discord_audit_permissions

Generate a permission audit report to identify who can access each channel in a Discord guild, ensuring proper access control.

Instructions

Generate a full permission audit report for a guild: who can access what on every channel.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guild_idYes

Implementation Reference

  • The implementation of the 'discord_audit_permissions' tool handler, which fetches guild data and generates a permission overwrite report.
    case "discord_audit_permissions": {
      const guild = await discord.guilds.fetch(validateId(args.guild_id, "guild_id"));
      await guild.channels.fetch();
      await guild.roles.fetch();
      const memberIdsNeeded = new Set<string>();
      guild.channels.cache.forEach((ch) => {
        if (ch instanceof GuildChannel) {
          ch.permissionOverwrites.cache.forEach((ow) => {
            if (ow.type === 1) memberIdsNeeded.add(ow.id);
          });
        }
      });
      await Promise.all([...memberIdsNeeded].map((id) => guild.members.fetch(id).catch(() => null)));
      const report: Record<string, unknown>[] = [];
      guild.channels.cache
        .filter((c) => c instanceof GuildChannel)
        .forEach((ch) => {
          const gch = ch as GuildChannel;
          const overwrites = gch.permissionOverwrites.cache.map((ow) => {
            const isRole = ow.type === 0;
            const entity = isRole
              ? guild.roles.cache.get(ow.id)?.name ?? ow.id
              : guild.members.cache.get(ow.id)?.user.tag ?? ow.id;
            return { entity, type: isRole ? "role" : "member", allow: serializePermissions(ow.allow), deny: serializePermissions(ow.deny) };
          });
          if (overwrites.length > 0) report.push({ channel: gch.name, channelId: gch.id, overwrites });
        });
      return { content: [{ type: "text", text: JSON.stringify(report, null, 2) }] };
    }
  • The schema definition for the 'discord_audit_permissions' tool.
      name: "discord_audit_permissions",
      description: "Generate a full permission audit report for a guild: who can access what on every channel.",
      inputSchema: {
        type: "object",
        properties: { guild_id: { type: "string" } },
        required: ["guild_id"],
      },
    },

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

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