discord_create_forum_post
Generate and publish a new post in a Discord forum channel, including a title, content, and optional tags, using the MCP-Discord server for streamlined communication.
Instructions
Creates a new post in a Discord forum channel with optional tags
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | ||
| forumChannelId | Yes | ||
| tags | No | ||
| title | Yes |
Implementation Reference
- src/tools/forum.ts:52-102 (handler)The main handler function that executes the Discord forum post creation using discord.js, including validation, tag resolution, and error handling.export const createForumPostHandler: ToolHandler = async (args, { client }) => { const { forumChannelId, title, content, tags } = CreateForumPostSchema.parse(args); try { if (!client.isReady()) { return { content: [{ type: "text", text: "Discord client not logged in." }], 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 handleDiscordError(error); } };
- src/schemas.ts:17-22 (schema)Zod runtime validation schema for the tool's input parameters.export const CreateForumPostSchema = z.object({ forumChannelId: z.string(), title: z.string(), content: z.string(), tags: z.array(z.string()).optional() });
- src/toolList.ts:77-93 (schema)JSON Schema definition for the tool, used by MCP for tool discovery and client-side 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"] } },
- src/server.ts:103-106 (registration)Tool handler registration and dispatch in the MCP server's tool execution switch statement.case "discord_create_forum_post": this.logClientState("before discord_create_forum_post handler"); toolResponse = await createForumPostHandler(args, this.toolContext); return toolResponse;