Skip to main content
Glama

create_forum_post

Create a new post in a Discord forum channel by specifying server, channel, title, and content. Apply tags and set auto-archive duration for organized discussions.

Instructions

Create a new post in a forum channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
channelIdYesThe ID of the forum channel
nameYesTitle of the post
contentYesContent of the initial message
appliedTagsNoTag IDs to apply
autoArchiveDurationNoAuto archive minutes
reasonNoReason for creating

Implementation Reference

  • The core handler function that executes the create_forum_post tool. It validates the channel is a forum channel, maps autoArchiveDuration, creates the thread with initial message and tags, and returns success/error response.
    async ({ guildId, channelId, name, content, appliedTags, autoArchiveDuration, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const channel = await guild.channels.fetch(channelId); if (!channel || channel.type !== ChannelType.GuildForum) { throw new Error('Channel is not a forum channel'); } const forumChannel = channel as ForumChannel; const archiveDurationMap: Record<string, ThreadAutoArchiveDuration> = { '60': ThreadAutoArchiveDuration.OneHour, '1440': ThreadAutoArchiveDuration.OneDay, '4320': ThreadAutoArchiveDuration.ThreeDays, '10080': ThreadAutoArchiveDuration.OneWeek, }; const thread = await forumChannel.threads.create({ name, message: { content }, appliedTags, autoArchiveDuration: autoArchiveDuration ? archiveDurationMap[autoArchiveDuration] : undefined, reason, }); return { id: thread.id, name: thread.name, parentId: thread.parentId, appliedTags: thread.appliedTags, message: 'Forum post created successfully', }; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; }
  • Zod input schema defining parameters for creating a forum post: guildId, channelId, name (title), content, optional tags, autoArchiveDuration, and reason.
    { guildId: z.string().describe('The ID of the server (guild)'), channelId: z.string().describe('The ID of the forum channel'), name: z.string().describe('Title of the post'), content: z.string().describe('Content of the initial message'), appliedTags: z.array(z.string()).optional().describe('Tag IDs to apply'), autoArchiveDuration: z.enum(['60', '1440', '4320', '10080']).optional().describe('Auto archive minutes'), reason: z.string().optional().describe('Reason for creating'), },
  • Registration of the 'create_forum_post' tool within registerThreadTools function using server.tool(name, description, schema, handler).
    server.tool( 'create_forum_post', 'Create a new post in a forum channel', { guildId: z.string().describe('The ID of the server (guild)'), channelId: z.string().describe('The ID of the forum channel'), name: z.string().describe('Title of the post'), content: z.string().describe('Content of the initial message'), appliedTags: z.array(z.string()).optional().describe('Tag IDs to apply'), autoArchiveDuration: z.enum(['60', '1440', '4320', '10080']).optional().describe('Auto archive minutes'), reason: z.string().optional().describe('Reason for creating'), }, async ({ guildId, channelId, name, content, appliedTags, autoArchiveDuration, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const channel = await guild.channels.fetch(channelId); if (!channel || channel.type !== ChannelType.GuildForum) { throw new Error('Channel is not a forum channel'); } const forumChannel = channel as ForumChannel; const archiveDurationMap: Record<string, ThreadAutoArchiveDuration> = { '60': ThreadAutoArchiveDuration.OneHour, '1440': ThreadAutoArchiveDuration.OneDay, '4320': ThreadAutoArchiveDuration.ThreeDays, '10080': ThreadAutoArchiveDuration.OneWeek, }; const thread = await forumChannel.threads.create({ name, message: { content }, appliedTags, autoArchiveDuration: autoArchiveDuration ? archiveDurationMap[autoArchiveDuration] : undefined, reason, }); return { id: thread.id, name: thread.name, parentId: thread.parentId, appliedTags: thread.appliedTags, message: 'Forum post created successfully', }; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } );
  • src/index.ts:64-64 (registration)
    Top-level call to registerThreadTools(server) in createMcpServer(), which includes the create_forum_post tool registration.
    registerThreadTools(server);
  • src/index.ts:21-21 (registration)
    Import of registerThreadTools from thread-tools.ts in the main index.ts file.
    import { registerThreadTools } from './tools/thread-tools.js';

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

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