Skip to main content
Glama

discord_create_webhook

Create a Discord webhook to automate messages in a specific channel. Provide channel ID and webhook name to set up automated notifications or integrations.

Instructions

Creates a new webhook for a Discord channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelIdYes
nameYes
avatarNo
reasonNo

Implementation Reference

  • The core handler function that implements the discord_create_webhook tool. It validates input using CreateWebhookSchema, fetches the channel, checks permissions, creates the webhook using discord.js channel.createWebhook, and returns success/error response.
    export async function createWebhookHandler(
      args: unknown,
      context: ToolContext
    ): Promise<ToolResponse> {
      const { channelId, name, avatar, reason } = CreateWebhookSchema.parse(args);
      try {
        if (!context.client.isReady()) {
          return {
            content: [{ type: 'text', text: 'Discord client not logged in.' }],
            isError: true,
          };
        }
    
        const channel = await context.client.channels.fetch(channelId);
        if (!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,
          avatar,
          reason,
        });
    
        return {
          content: [
            {
              type: 'text',
              text: `Successfully created webhook with ID: ${webhook.id} and token: ${webhook.token}`,
            },
          ],
        };
      } catch (error) {
        return handleDiscordError(error);
      }
    }
  • Zod schema for validating input parameters of the discord_create_webhook tool: channelId (required), name (required), avatar (optional), reason (optional). Used in the handler for parsing args.
    export const CreateWebhookSchema = z.object({
      channelId: z.string(),
      name: z.string(),
      avatar: z.string().optional(),
      reason: z.string().optional(),
    });
  • Tool registration entry in the toolList array, defining name, description, and inputSchema. This is returned by list_tools endpoint.
    {
      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'],
      },
    },
  • src/server.ts:186-189 (registration)
    Switch case in DiscordMCPServer that dispatches 'discord_create_webhook' calls to the createWebhookHandler function.
    case 'discord_create_webhook':
      this.logClientState('before discord_create_webhook handler');
      toolResponse = await createWebhookHandler(args, this.toolContext);
      return toolResponse;
  • Re-export of the webhook handlers, including createWebhookHandler, allowing centralized imports from './tools/tools.js' used in server.ts and transport.ts.
      createWebhookHandler,
      deleteWebhookHandler,
      editWebhookHandler,
      sendWebhookMessageHandler,
    } from './webhooks.js';
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states it 'creates' (implying a write/mutation operation) but doesn't disclose permissions needed, rate limits, whether the webhook is immediately usable, or what happens on failure. This leaves critical behavioral traits undocumented 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 that directly states the tool's purpose without unnecessary words. It's appropriately sized for a basic tool definition, though its brevity contributes to gaps in other dimensions.

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 4 parameters (2 required), 0% schema coverage, no annotations, and no output schema, the description is incomplete. It lacks parameter details, behavioral context, usage guidelines, and output information, making it inadequate for safe and effective use by an AI agent.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate but adds no parameter information. It doesn't explain what 'channelId', 'name', 'avatar', or 'reason' mean, their formats (e.g., ID structure, avatar encoding), or constraints (e.g., name length). This leaves all 4 parameters semantically unclear beyond their names.

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 clearly states the action ('creates') and resource ('new webhook for a Discord channel'), making the purpose immediately understandable. It distinguishes from siblings like discord_delete_webhook and discord_edit_webhook by specifying creation, though it doesn't explicitly differentiate from other creation tools like discord_create_category or discord_create_text_channel.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing channel access), when not to use it (e.g., for existing webhooks), or refer to sibling tools like discord_edit_webhook for modifications or discord_send_webhook_message for usage after creation.

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

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