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
| 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)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'), },
- src/tools/permission-tools.ts:128-161 (registration)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';