Skip to main content
Glama
jar285

MCP-Discord

by jar285

discord_create_forum_post

Create organized discussions in Discord forum channels by posting new topics with relevant tags to categorize conversations effectively.

Instructions

Creates a new post in a Discord forum channel with optional tags

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
forumChannelIdYes
titleYes
contentYes
tagsNo

Implementation Reference

  • The handler function for discord_create_forum_post that parses arguments using CreateForumPostSchema, validates the forum channel, handles optional tags by matching names to IDs, creates the forum thread/post using discord.js, and returns success message with thread ID or error.
    case "discord_create_forum_post": {
      const { forumChannelId, title, content, tags } = CreateForumPostSchema.parse(args);
      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(forumChannelId);
        if (!channel || channel.type !== ChannelType.GuildForum) {
          return {
            content: [{ type: "text", text: `Channel ID ${forumChannelId} is not a forum channel.` }],
            isError: true
          };
        }
    
        const forumChannel = channel as ForumChannel;
        
        // Get available tags in the forum
        const availableTags = forumChannel.availableTags;
        let selectedTagIds: string[] = [];
        
        // If tags are provided, find their IDs
        if (tags && tags.length > 0) {
          selectedTagIds = availableTags
            .filter(tag => tags.includes(tag.name))
            .map(tag => tag.id);
        }
    
        // Create the forum post
        const thread = await forumChannel.threads.create({
          name: title,
          message: {
            content: content
          },
          appliedTags: selectedTagIds.length > 0 ? selectedTagIds : undefined
        });
    
        return {
          content: [{ 
            type: "text", 
            text: `Successfully created forum post "${title}" with ID: ${thread.id}` 
          }]
        };
      } catch (error) {
        return {
          content: [{ type: "text", text: `Failed to create forum post: ${error}` }],
          isError: true
        };
      }
    }
  • Zod schema defining the input parameters for discord_create_forum_post: forumChannelId (required string), title (required string), content (required string), tags (optional array of strings).
    const CreateForumPostSchema = z.object({
        forumChannelId: z.string(),
        title: z.string(),
        content: z.string(),
        tags: z.array(z.string()).optional()
    });
  • src/index.ts:238-254 (registration)
    Tool registration in the MCP server's tools list, specifying name, description, and JSON schema matching the Zod schema for input validation.
    {
      name: "discord_create_forum_post",
      description: "Creates a new post in a Discord forum channel with optional tags",
      inputSchema: {
        type: "object",
        properties: {
          forumChannelId: { type: "string" },
          title: { type: "string" },
          content: { type: "string" },
          tags: { 
            type: "array",
            items: { type: "string" }
          }
        },
        required: ["forumChannelId", "title", "content"]
      }
    },

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