Skip to main content
Glama

discord_delete_channel

Remove a Discord channel using its channel ID and optionally specify a reason. This tool is part of the MCP-Discord server, which facilitates AI-driven Discord management tasks.

Instructions

Deletes a Discord channel with an optional reason

Input Schema

NameRequiredDescriptionDefault
channelIdYes
reasonNo

Input Schema (JSON Schema)

{ "properties": { "channelId": { "type": "string" }, "reason": { "type": "string" } }, "required": [ "channelId" ], "type": "object" }

Implementation Reference

  • The main handler function that parses arguments using DeleteChannelSchema, fetches the Discord channel, validates it supports deletion, and deletes it using channel.delete(). Handles errors and client readiness.
    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); } }
  • Zod schema used for input validation in the deleteChannelHandler, defining channelId as required string and reason as optional string.
    export const DeleteChannelSchema = z.object({ channelId: z.string(), reason: z.string().optional() });
  • MCP tool definition including name, description, and JSON inputSchema advertised via ListTools.
    { 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/server.ts:128-131 (registration)
    Switch case in CallToolRequest handler that dispatches to deleteChannelHandler for the "discord_delete_channel" tool.
    case "discord_delete_channel": this.logClientState("before discord_delete_channel handler"); toolResponse = await deleteChannelHandler(args, this.toolContext); return toolResponse;

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

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