Skip to main content
Glama
jar285

MCP-Discord

by jar285

discord_create_webhook

Create a Discord webhook to automate message delivery and integrate external services with specific channels, enabling automated notifications and data flow.

Instructions

Creates a new webhook for a Discord channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelIdYes
nameYes
avatarNo
reasonNo

Implementation Reference

  • The switch case handler that executes the discord_create_webhook tool. It validates input using CreateWebhookSchema, fetches the channel, creates a webhook using channel.createWebhook(), and returns the webhook ID and token on success.
    case "discord_create_webhook": {
      const { channelId, name, avatar, reason } = CreateWebhookSchema.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 channel = await client.channels.fetch(channelId);
        if (!channel || !channel.isTextBased()) {
          return {
            content: [{ type: "text", text: `Cannot find text channel with ID: ${channelId}` }],
            isError: true
          };
        }
    
        // Check if the channel supports webhooks
        if (!('createWebhook' in channel)) {
          return {
            content: [{ type: "text", text: `Channel type does not support webhooks: ${channelId}` }],
            isError: true
          };
        }
    
        // Create the webhook
        const webhook = await channel.createWebhook({
          name: name,
          avatar: avatar,
          reason: reason
        });
    
        return {
          content: [{ 
            type: "text", 
            text: `Successfully created webhook with ID: ${webhook.id} and token: ${webhook.token}` 
          }]
        };
      } catch (error) {
        return {
          content: [{ type: "text", text: `Failed to create webhook: ${error}` }],
          isError: true
        };
      }
    }
  • Zod schema defining the input parameters for the discord_create_webhook tool: channelId (required), name (required), avatar (optional), reason (optional). Used for validation in the handler.
    const CreateWebhookSchema = z.object({
        channelId: z.string(),
        name: z.string(),
        avatar: z.string().optional(),
        reason: z.string().optional()
    });
  • src/index.ts:399-411 (registration)
    Tool registration in the MCP server's listTools response. Specifies the tool name, description, and inputSchema matching the CreateWebhookSchema.
    {
      name: "discord_create_webhook",
      description: "Creates a new webhook for a Discord channel",
      inputSchema: {
        type: "object",
        properties: {
          channelId: { type: "string" },
          name: { type: "string" },
          avatar: { type: "string" },
          reason: { type: "string" }
        },
        required: ["channelId", "name"]
      }

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

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