Skip to main content
Glama

discord_send_webhook_message

Send messages to a Discord channel using a webhook. Configure webhook details, content, username, avatar, and thread ID for precise message delivery.

Instructions

Sends a message to a Discord channel using a webhook

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
avatarURLNo
contentYes
threadIdNo
usernameNo
webhookIdYes
webhookTokenYes

Implementation Reference

  • The core handler function that validates input using SendWebhookMessageSchema, fetches the Discord webhook, sends the message with provided content and options, handles errors, and returns appropriate ToolResponse.
    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: content, username: username, avatarURL: avatarURL, threadId: threadId }); return { content: [{ type: "text", text: `Successfully sent webhook message to webhook ID: ${webhookId}` }] }; } catch (error) { return handleDiscordError(error); } }
  • src/server.ts:168-171 (registration)
    Switch case in server that registers and dispatches calls to the sendWebhookMessageHandler function.
    case "discord_send_webhook_message": this.logClientState("before discord_send_webhook_message handler"); toolResponse = await sendWebhookMessageHandler(args, this.toolContext); return toolResponse;
  • MCP tool definition including name, description, and input schema for registration in the tool list.
    { 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"] } },
  • Zod validation schema for the tool inputs, used inside the handler for parsing arguments.
    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() });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/barryyip0625/mcp-discord'

If you have feedback or need assistance with the MCP directory API, please join our Discord server