Skip to main content
Glama
scarecr0w12

discord-mcp

edit_message

Modify existing bot messages in Discord servers by updating content with specific channel, message, and server identifiers.

Instructions

Edit a message sent by the bot

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
channelIdYesThe ID of the channel
messageIdYesThe ID of the message to edit
contentYesThe new message content

Implementation Reference

  • The core handler function for the 'edit_message' tool. It uses Discord.js to fetch the guild, channel, and target message, validates the channel type, edits the message content, handles errors with withErrorHandling, and returns the updated message details or an error response.
    async ({ guildId, channelId, messageId, content }) => {
      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);
        const edited = await message.edit(content);
        return {
          messageId: edited.id,
          content: edited.content,
          editedAt: edited.editedAt?.toISOString(),
        };
      });
    
      if (!result.success) {
        return { content: [{ type: 'text', text: result.error }], isError: true };
      }
    
      return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
    }
  • Zod schema defining the input parameters for the 'edit_message' tool: guildId, channelId, messageId, and new content.
    {
      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 edit'),
      content: z.string().describe('The new message content'),
    },
  • The server.tool registration call that defines, registers the 'edit_message' tool with MCP server, including name, description, input schema, and handler function.
    server.tool(
      'edit_message',
      'Edit a message sent by the bot',
      {
        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 edit'),
        content: z.string().describe('The new message content'),
      },
      async ({ guildId, channelId, messageId, content }) => {
        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);
          const edited = await message.edit(content);
          return {
            messageId: edited.id,
            content: edited.content,
            editedAt: edited.editedAt?.toISOString(),
          };
        });
    
        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 validate if a channel supports sending messages, used in the edit_message handler and other message tools.
    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:16-59 (registration)
    Higher-level registration: imports registerMessageTools and calls it on the MCP server instance, which in turn registers the edit_message tool.
    import { registerMessageTools } from './tools/message-tools.js';
    import { registerEmojiTools } from './tools/emoji-tools.js';
    import { registerWebhookTools } from './tools/webhook-tools.js';
    import { registerInviteTools } from './tools/invite-tools.js';
    import { registerEventTools } from './tools/event-tools.js';
    import { registerThreadTools } from './tools/thread-tools.js';
    import { registerAuditTools } from './tools/audit-tools.js';
    import { registerDiscordPrompts } from './prompts/discord-prompts.js';
    
    /**
     * Discord MCP Server
     *
     * This MCP server provides comprehensive tools for managing Discord servers.
     * It requires the DISCORD_BOT_TOKEN environment variable to be set.
     *
     * Available tool categories:
     * - Server Management: list_servers, get_server_info, modify_server
     * - Channel Management: list_channels, get_channel_info, create_channel, delete_channel, modify_channel
     * - Member Management: list_members, get_member_info, modify_member, kick_member, ban_member, unban_member, list_bans
     * - Role Management: list_roles, get_role_info, create_role, delete_role, modify_role, assign_role, remove_role
     * - Permission Management: get_channel_permissions, set_channel_permission, delete_channel_permission, list_permissions, sync_channel_permissions
     * - Message Management: send_message, get_messages, edit_message, delete_message, bulk_delete_messages, pin/unpin, reactions
     * - Emoji & Sticker Management: list_emojis, create_emoji, delete_emoji, modify_emoji, sticker operations
     * - Webhook Management: list_channel_webhooks, list_guild_webhooks, create_webhook, delete_webhook, modify_webhook, send_webhook_message
     * - Invite Management: list_invites, get_invite_info, create_invite, delete_invite
     * - Event Management: list_events, get_event_info, create_event, modify_event, delete_event, get_event_subscribers
     * - Thread Management: list_threads, create_thread, create_forum_post, modify_thread, delete_thread, join/leave, member management
     * - Audit & Moderation: get_audit_logs, list_audit_log_types, list_automod_rules, get_automod_rule, delete_automod_rule, toggle_automod_rule
     */
    
    // Create a configured MCP server instance
    function createMcpServer(): McpServer {
      const server = new McpServer({
        name: 'discord-mcp',
        version: '1.1.0',
      });
    
      // Register all tool categories
      registerServerTools(server);
      registerChannelTools(server);
      registerMemberTools(server);
      registerRoleTools(server);
      registerPermissionTools(server);
      registerMessageTools(server);
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 only states the basic action. It doesn't disclose behavioral traits like required bot permissions, rate limits, whether edits are reversible, or how the tool handles errors (e.g., invalid message IDs). This is inadequate 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 target, making it easy to parse quickly.

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 insufficient. It doesn't cover behavioral aspects (permissions, side effects), response format, or error handling. Given the complexity of editing messages in a Discord-like context, 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 the schema fully documents all 4 parameters (guildId, channelId, messageId, content). The description adds no additional meaning beyond implying 'messageId' refers to a bot-sent message, which is already inferred. Baseline 3 is appropriate as the schema does the heavy lifting.

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 ('Edit') and target ('a message sent by the bot'), which is specific and unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'modify_channel' or 'modify_member', though the focus on bot-sent messages provides some implicit distinction.

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 'send_message' for new messages or 'delete_message' for removal. It lacks context about prerequisites (e.g., bot permissions) or exclusions (e.g., editing others' messages), leaving usage unclear.

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