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
| Name | Required | Description | Default |
|---|---|---|---|
| forumChannelId | Yes | ||
| title | Yes | ||
| content | Yes | ||
| tags | No |
Implementation Reference
- src/tools/forum.ts:70-128 (handler)The core handler function that implements the discord_create_forum_post tool logic. It validates input with Zod, fetches the forum channel, handles tags, creates the thread/post, and returns success/error responses.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, }, 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/tool-list.ts:77-93 (schema)The JSON input schema definition for the tool, used by MCP for tool listing and 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:118-121 (registration)Registration and dispatch in the main server handler switch statement, calling the createForumPostHandler.case 'discord_create_forum_post': this.logClientState('before discord_create_forum_post handler'); toolResponse = await createForumPostHandler(args, this.toolContext); return toolResponse;
- src/server.ts:79-80 (registration)Tool list registration where the schema is provided to MCP clients.this.server.setRequestHandler(ListToolsRequestSchema, () => ({ tools: toolList,
- src/schemas.ts:16-22 (schema)Zod schema for internal input validation in the handler.export const CreateForumPostSchema = z.object({ forumChannelId: z.string(), title: z.string(), content: z.string(), tags: z.array(z.string()).optional(), });