discord_send_webhook_message
Send messages to Discord channels using webhook credentials, with options for custom content, usernames, avatars, and rich embeds.
Instructions
Send a message via a webhook using its ID and token.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| webhook_id | Yes | ||
| webhook_token | Yes | ||
| content | No | Text content of the message. | |
| username | No | Override the webhook's default username. | |
| avatar_url | No | Override the webhook's default avatar. | |
| embeds | No | Optional array of embed objects. |
Implementation Reference
- src/tools/webhooks.ts:141-164 (handler)Handler logic for the discord_send_webhook_message tool, which constructs a WebhookClient and sends a message with optional content and embeds.
case "discord_send_webhook_message": { const webhookId = validateId(args.webhook_id, "webhook_id"); const token = args.webhook_token as string; if (!token) throw new Error("webhook_token is required."); const client = new WebhookClient({ id: webhookId, token }); try { const sendOptions: Record<string, unknown> = {}; if (args.content) sendOptions.content = args.content as string; if (args.username) sendOptions.username = args.username as string; if (args.avatar_url) sendOptions.avatarURL = args.avatar_url as string; if (args.embeds) { const embedArgs = args.embeds as Record<string, unknown>[]; if (embedArgs.length > 10) throw new Error("Discord allows a maximum of 10 embeds per message."); sendOptions.embeds = embedArgs.map((e) => buildWebhookEmbed(e)); } if (!sendOptions.content && !sendOptions.embeds) { throw new Error("At least one of content or embeds is required."); } const sent = await client.send(sendOptions); return { content: [{ type: "text", text: `✅ Webhook message sent (id: ${sent.id}).` }] }; } finally { client.destroy(); } } - src/tools/webhooks.ts:20-63 (schema)Input schema definition for the discord_send_webhook_message tool.
{ name: "discord_send_webhook_message", description: "Send a message via a webhook using its ID and token.", inputSchema: { type: "object", properties: { webhook_id: { type: "string" }, webhook_token: { type: "string" }, content: { type: "string", description: "Text content of the message." }, username: { type: "string", description: "Override the webhook's default username." }, avatar_url: { type: "string", description: "Override the webhook's default avatar." }, embeds: { type: "array", description: "Optional array of embed objects.", items: { type: "object", properties: { title: { type: "string" }, url: { type: "string" }, description: { type: "string" }, color: { type: "string", description: "Hex color e.g. #5865F2" }, fields: { type: "array", items: { type: "object", properties: { name: { type: "string" }, value: { type: "string" }, inline: { type: "boolean" }, }, required: ["name", "value"], }, }, footer: { type: "string" }, image_url: { type: "string" }, thumbnail_url: { type: "string" }, timestamp: { type: "boolean" }, }, }, }, }, required: ["webhook_id", "webhook_token"], }, },