discord_send_webhook_message
Sends messages to Discord channels using webhooks by specifying webhook ID, token, and content. Supports custom usernames, avatars, and thread targeting.
Instructions
Sends a message to a Discord channel using a webhook
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| avatarURL | No | ||
| content | Yes | ||
| threadId | No | ||
| username | No | ||
| webhookId | Yes | ||
| webhookToken | Yes |
Input Schema (JSON Schema)
{
"properties": {
"avatarURL": {
"type": "string"
},
"content": {
"type": "string"
},
"threadId": {
"type": "string"
},
"username": {
"type": "string"
},
"webhookId": {
"type": "string"
},
"webhookToken": {
"type": "string"
}
},
"required": [
"webhookId",
"webhookToken",
"content"
],
"type": "object"
}
Implementation Reference
- src/index.ts:1267-1306 (handler)Executes the tool logic: validates input, fetches Discord webhook, sends message with optional username, avatarURL, threadId.case "discord_send_webhook_message": { const { webhookId, webhookToken, content, username, avatarURL, threadId } = SendWebhookMessageSchema.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 webhook = await 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: content, username: username, avatarURL: avatarURL, threadId: threadId }); return { content: [{ type: "text", text: `Successfully sent webhook message to webhook ID: ${webhookId}` }] }; } catch (error) { return { content: [{ type: "text", text: `Failed to send webhook message: ${error}` }], isError: true }; } }
- src/index.ts:128-135 (schema)Zod input schema for validating tool arguments: webhookId, webhookToken, content (required); username, avatarURL, threadId (optional).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/index.ts:413-428 (registration)Registers the tool in the MCP server's listTools handler with name, description, and input 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"] } },