Skip to main content
Glama
scarecr0w12

discord-mcp

delete_channel_permission

Remove permission overwrites for roles or members on Discord channels to manage access control and resolve conflicts.

Instructions

Delete a permission overwrite for a role or member on a channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
channelIdYesThe ID of the channel
targetIdYesThe ID of the role or member
reasonNoReason for the deletion

Implementation Reference

  • Handler function that fetches the guild and channel, deletes the permission overwrite for the targetId, and returns success/error response.
    async ({ guildId, channelId, targetId, reason }) => {
      const result = await withErrorHandling(async () => {
        const client = await getDiscordClient();
        const guild = await client.guilds.fetch(guildId);
        const channel = await guild.channels.fetch(channelId);
        if (!channel) throw new Error('Channel not found');
    
        const guildChannel = channel as GuildChannel;
        await guildChannel.permissionOverwrites.delete(targetId, reason);
    
        return {
          channelId,
          channelName: channel.name,
          targetId,
          message: 'Permission overwrite deleted successfully',
        };
      });
    
      if (!result.success) {
        return { content: [{ type: 'text', text: result.error }], isError: true };
      }
    
      return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
    }
  • Input schema using Zod for validating guildId, channelId, targetId, and optional reason.
    {
      guildId: z.string().describe('The ID of the server (guild)'),
      channelId: z.string().describe('The ID of the channel'),
      targetId: z.string().describe('The ID of the role or member'),
      reason: z.string().optional().describe('Reason for the deletion'),
    },
  • Registers the 'delete_channel_permission' tool on the MCP server with name, description, input schema, and handler function.
    server.tool(
      'delete_channel_permission',
      'Delete a permission overwrite for a role or member on a channel',
      {
        guildId: z.string().describe('The ID of the server (guild)'),
        channelId: z.string().describe('The ID of the channel'),
        targetId: z.string().describe('The ID of the role or member'),
        reason: z.string().optional().describe('Reason for the deletion'),
      },
      async ({ guildId, channelId, targetId, reason }) => {
        const result = await withErrorHandling(async () => {
          const client = await getDiscordClient();
          const guild = await client.guilds.fetch(guildId);
          const channel = await guild.channels.fetch(channelId);
          if (!channel) throw new Error('Channel not found');
    
          const guildChannel = channel as GuildChannel;
          await guildChannel.permissionOverwrites.delete(targetId, reason);
    
          return {
            channelId,
            channelName: channel.name,
            targetId,
            message: 'Permission overwrite deleted successfully',
          };
        });
    
        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:58-58 (registration)
    Calls registerPermissionTools(server) within createMcpServer to register all permission tools including delete_channel_permission.
    registerPermissionTools(server);
  • src/index.ts:15-15 (registration)
    Imports the registerPermissionTools function from permission-tools.ts.
    import { registerPermissionTools } from './tools/permission-tools.js';

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