delete_channel_permission
Remove permission overwrites for roles or members on Discord channels to manage access control and channel security settings.
Instructions
Delete a permission overwrite for a role or member on a channel
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) | |
| channelId | Yes | The ID of the channel | |
| targetId | Yes | The ID of the role or member | |
| reason | No | Reason for the deletion |
Implementation Reference
- src/tools/permission-tools.ts:137-160 (handler)The handler function that executes the tool: fetches guild and channel, deletes the permission overwrite using Discord.js `permissionOverwrites.delete()`, handles errors with `withErrorHandling`, and returns JSON 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'), },
- src/tools/permission-tools.ts:128-161 (registration)The MCP `server.tool()` registration defining name, description, schema, and handler for delete_channel_permission.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:57-57 (registration)Top-level call to registerPermissionTools which registers the delete_channel_permission tool among others.registerPermissionTools(server);