discord_send
Send messages to Discord text channels by specifying channel ID and message content for automated communication.
Instructions
Sends a message to a specified Discord text channel
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channelId | Yes | ||
| message | Yes |
Implementation Reference
- src/tools/send-message.ts:5-50 (handler)The sendMessageHandler function that executes the 'discord_send' tool: validates input, checks client readiness, fetches the channel, and sends the message.export const sendMessageHandler: ToolHandler = async (args, { client }) => { const { channelId, message } = SendMessageSchema.parse(args); try { if (!client.isReady()) { return { content: [{ type: 'text', text: 'Discord client not logged in.' }], isError: true, }; } const channel = await client.channels.fetch(channelId); if (!channel?.isTextBased()) { return { content: [ { type: 'text', text: `Cannot find text channel ID: ${channelId}` }, ], isError: true, }; } // Ensure channel is text-based and can send messages if ('send' in channel) { await channel.send(message); return { content: [ { type: 'text', text: `Message successfully sent to channel ID: ${channelId}`, }, ], }; } return { content: [ { type: 'text', text: 'This channel type does not support sending messages', }, ], isError: true, }; } catch (error) { return handleDiscordError(error); } };
- src/tool-list.ts:53-64 (schema)Input schema for 'discord_send' exposed in the tool list for MCP listTools request.{ name: 'discord_send', description: 'Sends a message to a specified Discord text channel', inputSchema: { type: 'object', properties: { channelId: { type: 'string' }, message: { type: 'string' }, }, required: ['channelId', 'message'], }, },
- src/server.ts:105-108 (registration)Registration and dispatching of 'discord_send' to sendMessageHandler in the MCP server's CallToolRequest handler.case 'discord_send': this.logClientState('before discord_send handler'); toolResponse = await sendMessageHandler(args, this.toolContext); return toolResponse;
- src/schemas.ts:7-10 (schema)Zod schema for input validation used within the sendMessageHandler.export const SendMessageSchema = z.object({ channelId: z.string(), message: z.string(), });
- src/tools/tools.ts:24-24 (registration)Re-export of sendMessageHandler for convenient import in server.ts.export { sendMessageHandler } from './send-message.js';