Skip to main content
Glama

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
NameRequiredDescriptionDefault
webhookIdYes
webhookTokenYes
contentYes
usernameNo
avatarURLNo
threadIdNo

Implementation Reference

  • 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); } }
  • 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(), });
  • 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;
  • Re-export of the sendWebhookMessageHandler (and related webhook handlers) for convenient import in server.ts and transport.ts.
    createWebhookHandler, deleteWebhookHandler, editWebhookHandler, sendWebhookMessageHandler,

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/IQAIcom/mcp-discord'

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