Skip to main content
Glama
scarecr0w12

discord-mcp

delete_message

Remove messages from Discord channels by specifying server, channel, and message IDs to manage content and maintain server organization.

Instructions

Delete a message from a channel

Input Schema

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

Implementation Reference

  • The main execution logic for the 'delete_message' tool. Fetches the Discord guild, channel, and message, validates the channel type, deletes the message, handles errors with withErrorHandling, and returns a formatted response.
    async ({ guildId, channelId, messageId, 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 message = await channel.messages.fetch(messageId);
        await message.delete();
        return { messageId, message: 'Message 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) }] };
    }
  • Zod input schema defining parameters for delete_message: required guildId, channelId, messageId; optional reason.
    {
      guildId: z.string().describe('The ID of the server (guild)'),
      channelId: z.string().describe('The ID of the channel'),
      messageId: z.string().describe('The ID of the message to delete'),
      reason: z.string().optional().describe('Reason for deletion'),
    },
  • The server.tool() registration call for 'delete_message', including name, description, input schema, and handler within the registerMessageTools function.
    server.tool(
      'delete_message',
      'Delete a message from a channel',
      {
        guildId: z.string().describe('The ID of the server (guild)'),
        channelId: z.string().describe('The ID of the channel'),
        messageId: z.string().describe('The ID of the message to delete'),
        reason: z.string().optional().describe('Reason for deletion'),
      },
      async ({ guildId, channelId, messageId, 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 message = await channel.messages.fetch(messageId);
          await message.delete();
          return { messageId, message: 'Message 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) }] };
      }
    );
  • src/index.ts:59-59 (registration)
    Invocation of registerMessageTools(server) in createMcpServer(), which registers all message tools including delete_message.
    registerMessageTools(server);
  • Type guard helper function used in the delete_message handler (and others) to validate if a channel is messageable (Text, News, Thread channels).
    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;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool performs a deletion, implying a destructive mutation, but fails to mention critical aspects like whether the action is reversible, what permissions are needed, potential rate limits, or the response format. This leaves significant gaps in understanding the tool's behavior and risks.

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, direct sentence with zero wasted words, making it highly efficient and front-loaded. It immediately conveys the core action without unnecessary elaboration, which is ideal for quick comprehension by an AI agent.

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?

Given the tool's destructive nature, lack of annotations, and absence of an output schema, the description is insufficiently complete. It doesn't address behavioral risks, permission requirements, error conditions, or what happens post-deletion, leaving the agent poorly equipped to use this tool safely and effectively in context.

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?

The input schema has 100% description coverage, clearly documenting all four parameters (guildId, channelId, messageId, reason). The description adds no additional semantic context beyond what the schema provides, such as explaining parameter relationships or usage nuances, so it meets the baseline score for high schema coverage without adding value.

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 ('Delete') and resource ('a message from a channel'), making the purpose immediately understandable. However, it doesn't distinguish this tool from similar destructive operations like 'bulk_delete_messages' or 'delete_channel' among the sibling tools, which would require explicit differentiation to earn a perfect score.

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 like 'bulk_delete_messages' for multiple messages or 'edit_message' for modification instead of deletion. It also lacks information about prerequisites such as required permissions or contextual constraints, leaving usage decisions ambiguous for the agent.

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