discord_add_reaction
React to a specific Discord message with an emoji by providing the channel ID, message ID, and emoji identifier. Simplifies emoji interaction in Discord via MCP-Discord server.
Instructions
Adds an emoji reaction to a specific Discord message
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channelId | Yes | ||
| emoji | Yes | ||
| messageId | Yes |
Implementation Reference
- src/tools/reactions.ts:12-53 (handler)The main handler function that parses arguments using AddReactionSchema, fetches the channel and message, adds the reaction using Discord.js message.react(emoji), and returns success or error response.
export async function addReactionHandler( args: unknown, context: ToolContext ): Promise<ToolResponse> { const { channelId, messageId, emoji } = AddReactionSchema.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 || !channel.isTextBased() || !('messages' in channel)) { return { content: [{ type: "text", text: `Cannot find text channel with ID: ${channelId}` }], isError: true }; } const message = await channel.messages.fetch(messageId); if (!message) { return { content: [{ type: "text", text: `Cannot find message with ID: ${messageId}` }], isError: true }; } // Add the reaction await message.react(emoji); return { content: [{ type: "text", text: `Successfully added reaction ${emoji} to message ID: ${messageId}` }] }; } catch (error) { return handleDiscordError(error); } } - src/schemas.ts:74-78 (schema)Zod schema for input validation of the discord_add_reaction tool parameters: channelId, messageId, emoji.
export const AddReactionSchema = z.object({ channelId: z.string(), messageId: z.string(), emoji: z.string() }); - src/server.ts:143-146 (registration)Switch case in server.ts that registers and dispatches the discord_add_reaction tool call to the addReactionHandler function.
case "discord_add_reaction": this.logClientState("before discord_add_reaction handler"); toolResponse = await addReactionHandler(args, this.toolContext); return toolResponse; - src/toolList.ts:170-182 (schema)MCP tool definition including name, description, and JSON input schema for the discord_add_reaction tool, used in listTools response.
{ name: "discord_add_reaction", description: "Adds an emoji reaction to a specific Discord message", inputSchema: { type: "object", properties: { channelId: { type: "string" }, messageId: { type: "string" }, emoji: { type: "string" } }, required: ["channelId", "messageId", "emoji"] } }, - src/server.ts:66-70 (registration)Registration of the tool list handler that returns the toolList containing the discord_add_reaction tool definition.
this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: toolList }; });