discord_create_webhook
Create a new webhook for a Discord channel using the MCP-Discord server, enabling automated message delivery and integration for streamlined communication.
Instructions
Creates a new webhook for a Discord channel
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| avatar | No | ||
| channelId | Yes | ||
| name | Yes | ||
| reason | No |
Implementation Reference
- src/index.ts:1220-1265 (handler)Handler that executes the discord_create_webhook tool: validates input, fetches channel, creates webhook using Discord.js channel.createWebhook method, returns webhook ID and token.case "discord_create_webhook": { const { channelId, name, avatar, reason } = CreateWebhookSchema.parse(args); try { if (!client.isReady()) { return { content: [{ type: "text", text: "Discord client not logged in. Please use discord_login tool first." }], isError: true }; } const channel = await client.channels.fetch(channelId); if (!channel || !channel.isTextBased()) { return { content: [{ type: "text", text: `Cannot find text channel with ID: ${channelId}` }], isError: true }; } // Check if the channel supports webhooks if (!('createWebhook' in channel)) { return { content: [{ type: "text", text: `Channel type does not support webhooks: ${channelId}` }], isError: true }; } // Create the webhook const webhook = await channel.createWebhook({ name: name, avatar: avatar, reason: reason }); return { content: [{ type: "text", text: `Successfully created webhook with ID: ${webhook.id} and token: ${webhook.token}` }] }; } catch (error) { return { content: [{ type: "text", text: `Failed to create webhook: ${error}` }], isError: true }; } }
- src/index.ts:121-126 (schema)Zod schema defining input parameters for the discord_create_webhook tool: channelId (required), name (required), avatar (optional), reason (optional). Used for validation in handler and inputSchema in registration.const CreateWebhookSchema = z.object({ channelId: z.string(), name: z.string(), avatar: z.string().optional(), reason: z.string().optional() });
- src/index.ts:399-412 (registration)Tool registration in the ListTools response: defines name, description, and inputSchema matching the CreateWebhookSchema.{ name: "discord_create_webhook", description: "Creates a new webhook for a Discord channel", inputSchema: { type: "object", properties: { channelId: { type: "string" }, name: { type: "string" }, avatar: { type: "string" }, reason: { type: "string" } }, required: ["channelId", "name"] } },