Skip to main content
Glama

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
NameRequiredDescriptionDefault
webhook_idYes
webhook_tokenYes
contentNoText content of the message.
usernameNoOverride the webhook's default username.
avatar_urlNoOverride the webhook's default avatar.
embedsNoOptional array of embed objects.

Implementation Reference

  • 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();
      }
    }
  • 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"],
      },
    },

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

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