Skip to main content
Glama
scarecr0w12

discord-mcp

create_webhook

Create a Discord webhook in a specified channel to automate message delivery and integrate external services with your server.

Instructions

Create a webhook in a channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
channelIdYesThe ID of the channel
nameYesName for the webhook
avatarNoURL of the avatar image
reasonNoReason for creating

Implementation Reference

  • The handler function that executes the tool: fetches guild and channel, checks if channel supports webhooks, creates the webhook using Discord.js, handles errors with withErrorHandling, and returns JSON response.
    async ({ guildId, channelId, name, avatar, reason }) => {
      const result = await withErrorHandling(async () => {
        const client = await getDiscordClient();
        const guild = await client.guilds.fetch(guildId);
        const channel = await guild.channels.fetch(channelId);
        
        if (!isWebhookableChannel(channel)) {
          throw new Error('Channel does not support webhooks');
        }
    
        const webhook = await channel.createWebhook({ name, avatar, reason });
    
        return {
          id: webhook.id,
          name: webhook.name,
          channelId: webhook.channelId,
          token: webhook.token,
          url: webhook.url,
          message: 'Webhook created successfully',
        };
      });
    
      if (!result.success) {
        return { content: [{ type: 'text', text: result.error }], isError: true };
      }
    
      return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
    }
  • Zod input schema defining required parameters (guildId, channelId, name) and optional (avatar, reason).
    {
      guildId: z.string().describe('The ID of the server (guild)'),
      channelId: z.string().describe('The ID of the channel'),
      name: z.string().describe('Name for the webhook'),
      avatar: z.string().optional().describe('URL of the avatar image'),
      reason: z.string().optional().describe('Reason for creating'),
    },
  • The server.tool() call that registers the 'create_webhook' tool with name, description, input schema, and handler function on the MCP server.
    server.tool(
      'create_webhook',
      'Create a webhook in a channel',
      {
        guildId: z.string().describe('The ID of the server (guild)'),
        channelId: z.string().describe('The ID of the channel'),
        name: z.string().describe('Name for the webhook'),
        avatar: z.string().optional().describe('URL of the avatar image'),
        reason: z.string().optional().describe('Reason for creating'),
      },
      async ({ guildId, channelId, name, avatar, reason }) => {
        const result = await withErrorHandling(async () => {
          const client = await getDiscordClient();
          const guild = await client.guilds.fetch(guildId);
          const channel = await guild.channels.fetch(channelId);
          
          if (!isWebhookableChannel(channel)) {
            throw new Error('Channel does not support webhooks');
          }
    
          const webhook = await channel.createWebhook({ name, avatar, reason });
    
          return {
            id: webhook.id,
            name: webhook.name,
            channelId: webhook.channelId,
            token: webhook.token,
            url: webhook.url,
            message: 'Webhook created successfully',
          };
        });
    
        if (!result.success) {
          return { content: [{ type: 'text', text: result.error }], isError: true };
        }
    
        return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
      }
    );
  • Helper type guard function used in the handler to validate if the channel type supports webhooks.
    function isWebhookableChannel(channel: unknown): channel is WebhookableChannel {
      if (!channel || typeof channel !== 'object') return false;
      const ch = channel as { type?: number };
      return ch.type === ChannelType.GuildText || 
             ch.type === ChannelType.GuildAnnouncement ||
             ch.type === ChannelType.GuildVoice ||
             ch.type === ChannelType.GuildForum;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. 'Create' implies a write/mutation operation, but the description doesn't disclose behavioral traits like required permissions, whether this action is reversible (deletable via 'delete_webhook'), rate limits, what the tool returns (webhook URL/token), or error conditions. This leaves significant gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core action and resource, making it immediately understandable. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what happens after creation (e.g., returns webhook URL), required permissions, or error handling. Given the complexity of webhook creation and the lack of structured behavioral information, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so parameters are fully documented in the schema. The description adds no additional parameter semantics beyond implying 'channel' context (which aligns with 'channelId' parameter). With high schema coverage, the baseline is 3 even without parameter details in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Create a webhook in a channel' clearly states the action (create) and resource (webhook) with location context (in a channel). It distinguishes from siblings like 'modify_webhook' or 'delete_webhook' by specifying creation, but doesn't explicitly differentiate from other creation tools like 'create_channel' or 'create_invite' beyond the resource type.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., permissions needed), when webhooks are appropriate versus other messaging methods, or what happens after creation. With siblings like 'send_message' and 'send_webhook_message', some usage context would be helpful.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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

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