discord_send_webhook_message
Send automated messages to Discord channels using webhooks for notifications, alerts, or bot communications.
Instructions
Sends a message to a Discord channel using a webhook
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| webhookId | Yes | ||
| webhookToken | Yes | ||
| content | Yes | ||
| username | No | ||
| avatarURL | No | ||
| threadId | No |
Implementation Reference
- src/tools/webhooks.ts:71-114 (handler)Executes the Discord webhook message sending logic: parses input with SendWebhookMessageSchema, fetches webhook, sends message with options, handles errors.export async function sendWebhookMessageHandler( args: unknown, context: ToolContext ): Promise<ToolResponse> { const { webhookId, webhookToken, content, username, avatarURL, threadId } = SendWebhookMessageSchema.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, }; } // Send the message await webhook.send({ content, username, avatarURL, threadId, }); return { content: [ { type: 'text', text: `Successfully sent webhook message to webhook ID: ${webhookId}`, }, ], }; } catch (error) { return handleDiscordError(error); } }
- src/schemas.ts:110-117 (schema)Zod schema for input validation of the tool parameters: webhookId, webhookToken, content (required), and optional username, avatarURL, threadId.export const SendWebhookMessageSchema = z.object({ webhookId: z.string(), webhookToken: z.string(), content: z.string(), username: z.string().optional(), avatarURL: z.string().optional(), threadId: z.string().optional(), });
- src/tool-list.ts:256-271 (registration)MCP tool registration entry in the toolList array, defining name, description, and inputSchema matching the Zod schema.{ name: 'discord_send_webhook_message', description: 'Sends a message to a Discord channel using a webhook', inputSchema: { type: 'object', properties: { webhookId: { type: 'string' }, webhookToken: { type: 'string' }, content: { type: 'string' }, username: { type: 'string' }, avatarURL: { type: 'string' }, threadId: { type: 'string' }, }, required: ['webhookId', 'webhookToken', 'content'], }, },
- src/server.ts:191-197 (registration)Dispatch/registration in server request handler switch statement: calls sendWebhookMessageHandler with parsed args and tool context.case 'discord_send_webhook_message': this.logClientState('before discord_send_webhook_message handler'); toolResponse = await sendWebhookMessageHandler( args, this.toolContext ); return toolResponse;
- src/tools/tools.ts:27-30 (helper)Re-export of the sendWebhookMessageHandler (and related webhook handlers) for convenient import in server.ts and transport.ts.createWebhookHandler, deleteWebhookHandler, editWebhookHandler, sendWebhookMessageHandler,