Skip to main content
Glama
jar285

MCP-Discord

by jar285

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
NameRequiredDescriptionDefault
channelIdYes
messageYes

Implementation Reference

  • 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
        };
      }
    }
  • 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"]
      }
    },

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/jar285/mcp-discord'

If you have feedback or need assistance with the MCP directory API, please join our Discord server