discord_send
Send messages to Discord text channels using 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/index.ts:549-588 (handler)Handler for the 'discord_send' tool. Parses arguments using SendMessageSchema, checks if client is ready, fetches the text channel, sends the message, and returns success or error response.case "discord_send": { // Use default channel ID if not provided let parsedArgs = SendMessageSchema.parse(args); if (parsedArgs.channelId === 'default') { parsedArgs.channelId = process.env.DEFAULT_CHANNEL_ID || ''; } const { channelId, message } = parsedArgs; try { if (!client.isReady()) { return { content: [{ type: "text", text: "Discord client not logged in. Please use discord_login tool first." }], isError: true }; } const channel = await client.channels.fetch(channelId); if (!channel || !(channel instanceof TextChannel)) { return { content: [{ type: "text", text: `Cannot find text channel with ID: ${channelId}` }], isError: true }; } await channel.send(message); return { content: [{ type: "text", text: `Message sent to channel: ${channel.name}` }] }; } catch (error) { return { content: [{ type: "text", text: `Send message failed: ${error}` }], isError: true }; } }
- src/index.ts:76-79 (schema)Zod schema defining the input parameters for the discord_send tool: channelId (string) and message (string). Used for validation in the handler.const SendMessageSchema = z.object({ channelId: z.string(), message: z.string() });
- src/index.ts:215-226 (registration)Tool registration in the MCP server's ListTools response. Defines name, description, and inputSchema matching the SendMessageSchema.{ 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"] } },