discord_delete_webhook
Delete an existing Discord webhook to remove automated message delivery from a channel. This tool removes webhooks by ID and token, with optional audit log reason.
Instructions
Deletes an existing webhook for a Discord channel
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| webhookId | Yes | ||
| webhookToken | No | ||
| reason | No |
Implementation Reference
- src/tools/webhooks.ts:163-200 (handler)The core handler function that implements the discord_delete_webhook tool logic: validates input, fetches the webhook, deletes it, and handles errors.export async function deleteWebhookHandler( args: unknown, context: ToolContext ): Promise<ToolResponse> { const { webhookId, webhookToken, reason } = DeleteWebhookSchema.parse(args); try { if (!context.client.isReady()) { return { content: [{ type: 'text', text: 'Discord client not logged in.' }], isError: true, }; } const webhook = await context.client.fetchWebhook(webhookId, webhookToken); if (!webhook) { return { content: [ { type: 'text', text: `Cannot find webhook with ID: ${webhookId}` }, ], isError: true, }; } // Delete the webhook await webhook.delete(reason || 'Webhook deleted via API'); return { content: [ { type: 'text', text: `Successfully deleted webhook with ID: ${webhook.id}`, }, ], }; } catch (error) { return handleDiscordError(error); } }
- src/tool-list.ts:288-300 (schema)Tool metadata and input schema definition used for MCP tools/list response.{ name: 'discord_delete_webhook', description: 'Deletes an existing webhook for a Discord channel', inputSchema: { type: 'object', properties: { webhookId: { type: 'string' }, webhookToken: { type: 'string' }, reason: { type: 'string' }, }, required: ['webhookId'], }, },
- src/schemas.ts:128-132 (schema)Zod validation schema parsed in the handler for input parameters.export const DeleteWebhookSchema = z.object({ webhookId: z.string(), webhookToken: z.string().optional(), reason: z.string().optional(), });
- src/server.ts:204-207 (registration)Dispatch registration in the main MCP server CallToolRequestSchema handler switch statement.case 'discord_delete_webhook': this.logClientState('before discord_delete_webhook handler'); toolResponse = await deleteWebhookHandler(args, this.toolContext); return toolResponse;
- src/transport.ts:379-380 (registration)Dispatch case in the HTTP transport handler for direct method calls.case 'discord_delete_webhook': result = await deleteWebhookHandler(params, this.toolContext!);