Skip to main content
Glama
scarecr0w12

discord-mcp

bulk_delete_messages

Remove multiple messages from a Discord channel at once, supporting up to 100 messages that are less than 14 days old.

Instructions

Bulk delete messages from a channel (up to 100, messages must be < 14 days old)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
channelIdYesThe ID of the channel
messageIdsYesArray of message IDs to delete
reasonNoReason for deletion

Implementation Reference

  • Handler function executes bulk delete: fetches Discord client, guild, channel; validates channel type; bulkDeletes up to 100 messages; handles errors with withErrorHandling; returns JSON response.
    async ({ guildId, channelId, messageIds, 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 (!isMessageableChannel(channel)) {
          throw new Error('Channel does not support messages');
        }
    
        const deleted = await channel.bulkDelete(messageIds.slice(0, 100));
        return { deletedCount: deleted.size, message: 'Messages deleted successfully' };
      });
    
      if (!result.success) {
        return { content: [{ type: 'text', text: result.error }], isError: true };
      }
    
      return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
    }
  • Input schema using Zod: requires guildId, channelId, messageIds (string array); optional reason.
    {
      guildId: z.string().describe('The ID of the server (guild)'),
      channelId: z.string().describe('The ID of the channel'),
      messageIds: z.array(z.string()).describe('Array of message IDs to delete'),
      reason: z.string().optional().describe('Reason for deletion'),
    },
  • Full registration of the bulk_delete_messages tool using McpServer.tool() with name, description, schema, and handler.
    server.tool(
      'bulk_delete_messages',
      'Bulk delete messages from a channel (up to 100, messages must be < 14 days old)',
      {
        guildId: z.string().describe('The ID of the server (guild)'),
        channelId: z.string().describe('The ID of the channel'),
        messageIds: z.array(z.string()).describe('Array of message IDs to delete'),
        reason: z.string().optional().describe('Reason for deletion'),
      },
      async ({ guildId, channelId, messageIds, 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 (!isMessageableChannel(channel)) {
            throw new Error('Channel does not support messages');
          }
    
          const deleted = await channel.bulkDelete(messageIds.slice(0, 100));
          return { deletedCount: deleted.size, message: 'Messages deleted 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 function to type-guard if a channel is messageable (TextChannel, NewsChannel, or ThreadChannel). Used in the handler.
    function isMessageableChannel(channel: unknown): channel is MessageableChannel {
      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.PublicThread ||
             ch.type === ChannelType.PrivateThread ||
             ch.type === ChannelType.AnnouncementThread;
    }
  • src/index.ts:59-59 (registration)
    Top-level call to registerMessageTools(server), which registers bulk_delete_messages among other message tools.
    registerMessageTools(server);
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. It mentions the bulk deletion action and constraints, but lacks details on permissions required, whether deletions are reversible, rate limits, or error handling. For a destructive tool with zero annotation coverage, this is insufficient.

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 front-loads the purpose and key constraints without unnecessary words. Every part of the sentence adds value, making it appropriately sized and well-structured.

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

Completeness3/5

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

Given the tool's complexity (destructive bulk operation), lack of annotations, and no output schema, the description is incomplete. It covers basic constraints but misses critical behavioral context like permissions, reversibility, and response format, which are essential for safe usage.

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 the schema already documents all parameters. The description adds no additional parameter semantics beyond what the schema provides, such as format details for messageIds or reason usage. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose5/5

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

The description clearly states the action ('bulk delete'), resource ('messages'), and scope ('from a channel'), with specific constraints ('up to 100, messages must be < 14 days old'). It distinguishes from sibling 'delete_message' by emphasizing bulk operations and age limits.

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

Usage Guidelines4/5

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

The description provides clear context for usage with the constraints on message count (100) and age (14 days), which helps determine when to use this tool. However, it doesn't explicitly mention when to choose this over the sibling 'delete_message' tool for single deletions or other alternatives.

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