discord_send
Send messages directly to a Discord text channel using MCP-Discord server. Input channel ID and message content to enable AI assistants to communicate on Discord platforms efficiently.
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. Validates input using SendMessageSchema, fetches the Discord 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-78 (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)Registration of the 'discord_send' tool in the ListTools response, including name, description, and input schema matching the Zod schema.{ 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"] } },