discord_delete_channel
Delete Discord channels from your server using this MCP-Discord tool. Specify the channel ID and optional reason to remove unwanted channels.
Instructions
Deletes a Discord channel with an optional reason
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channelId | Yes | ||
| reason | No |
Implementation Reference
- src/tools/channel.ts:200-250 (handler)The core handler function that executes the Discord channel deletion logic using discord.js API, including validation, fetching, permission checks, and error handling.export async function deleteChannelHandler( args: unknown, context: ToolContext ): Promise<ToolResponse> { const { channelId, reason } = DeleteChannelSchema.parse(args); try { if (!context.client.isReady()) { return { content: [{ type: 'text', text: 'Discord client not logged in.' }], isError: true, }; } const channel = await context.client.channels.fetch(channelId); if (!channel) { return { content: [ { type: 'text', text: `Cannot find channel with ID: ${channelId}` }, ], isError: true, }; } // Check if channel can be deleted (has delete method) if (!('delete' in channel)) { return { content: [ { type: 'text', text: 'This channel type does not support deletion or the bot lacks permissions', }, ], isError: true, }; } // Delete the channel await channel.delete(reason || 'Channel deleted via API'); return { content: [ { type: 'text', text: `Successfully deleted channel with ID: ${channelId}`, }, ], }; } catch (error) { return handleDiscordError(error); } }
- src/tool-list.ts:132-143 (schema)MCP tool definition including name, description, and input schema for the tools/list endpoint.{ name: 'discord_delete_channel', description: 'Deletes a Discord channel with an optional reason', inputSchema: { type: 'object', properties: { channelId: { type: 'string' }, reason: { type: 'string' }, }, required: ['channelId'], }, },
- src/schemas.ts:59-62 (schema)Zod validation schema parsed in the handler for input arguments.export const DeleteChannelSchema = z.object({ channelId: z.string(), reason: z.string().optional(), });
- src/server.ts:146-149 (registration)Registration of the deleteChannelHandler in the MCP server's CallToolRequestSchema handler switch statement.case 'discord_delete_channel': this.logClientState('before discord_delete_channel handler'); toolResponse = await deleteChannelHandler(args, this.toolContext); return toolResponse;
- src/tools/tools.ts:2-6 (registration)Re-export of the handler from channel.ts for aggregation in tools.ts, imported by server.ts.createCategoryHandler, createTextChannelHandler, deleteCategoryHandler, deleteChannelHandler, editCategoryHandler,