create_channel
Create a new text, voice, or category channel in a Discord server to organize discussions and manage community spaces.
Instructions
Create a new channel in a Discord server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) | |
| name | Yes | Name of the new channel | |
| type | Yes | Type of channel | |
| parentId | No | ID of the parent category | |
| topic | No | Channel topic (text channels only) | |
| nsfw | No | Whether the channel is NSFW | |
| bitrate | No | Bitrate for voice channels | |
| userLimit | No | User limit for voice channels | |
| rateLimitPerUser | No | Slowmode in seconds | |
| position | No | Position of the channel | |
| reason | No | Reason for creating the channel |
Implementation Reference
- src/tools/channel-tools.ts:122-171 (registration)Registers the 'create_channel' tool on the MCP server, including description, Zod input schema for parameters like guildId, name, type, and the inline async handler function that creates a Discord channel using guild.channels.create() with error handling.server.tool( 'create_channel', 'Create a new channel in a Discord server', { guildId: z.string().describe('The ID of the server (guild)'), name: z.string().describe('Name of the new channel'), type: z.enum(['text', 'voice', 'category', 'announcement', 'forum', 'stage']).describe('Type of channel'), parentId: z.string().optional().describe('ID of the parent category'), topic: z.string().optional().describe('Channel topic (text channels only)'), nsfw: z.boolean().optional().describe('Whether the channel is NSFW'), bitrate: z.number().optional().describe('Bitrate for voice channels'), userLimit: z.number().optional().describe('User limit for voice channels'), rateLimitPerUser: z.number().optional().describe('Slowmode in seconds'), position: z.number().optional().describe('Position of the channel'), reason: z.string().optional().describe('Reason for creating the channel'), }, async ({ guildId, name, type, parentId, topic, nsfw, bitrate, userLimit, rateLimitPerUser, position, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const channelOptions: Record<string, unknown> = { name, type: channelTypeMap[type], parent: parentId, topic, nsfw, bitrate, userLimit, rateLimitPerUser, position, reason, }; // Remove undefined values Object.keys(channelOptions).forEach((key) => { if (channelOptions[key] === undefined) delete channelOptions[key]; }); const newChannel = await guild.channels.create(channelOptions as any); return { id: newChannel.id, name: newChannel.name, type: ChannelType[newChannel.type], message: 'Channel created' }; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } );
- src/tools/channel-tools.ts:138-169 (handler)The core handler logic for create_channel: fetches Discord guild, prepares channel creation options (mapping type, filtering undefined), calls guild.channels.create(), returns created channel info or error.async ({ guildId, name, type, parentId, topic, nsfw, bitrate, userLimit, rateLimitPerUser, position, reason }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const channelOptions: Record<string, unknown> = { name, type: channelTypeMap[type], parent: parentId, topic, nsfw, bitrate, userLimit, rateLimitPerUser, position, reason, }; // Remove undefined values Object.keys(channelOptions).forEach((key) => { if (channelOptions[key] === undefined) delete channelOptions[key]; }); const newChannel = await guild.channels.create(channelOptions as any); return { id: newChannel.id, name: newChannel.name, type: ChannelType[newChannel.type], message: 'Channel created' }; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
- src/tools/channel-tools.ts:125-137 (schema)Zod schema defining input parameters for create_channel tool: required guildId, name, type (enum: text/voice/etc.), optional parentId, topic, nsfw, bitrate, etc.{ guildId: z.string().describe('The ID of the server (guild)'), name: z.string().describe('Name of the new channel'), type: z.enum(['text', 'voice', 'category', 'announcement', 'forum', 'stage']).describe('Type of channel'), parentId: z.string().optional().describe('ID of the parent category'), topic: z.string().optional().describe('Channel topic (text channels only)'), nsfw: z.boolean().optional().describe('Whether the channel is NSFW'), bitrate: z.number().optional().describe('Bitrate for voice channels'), userLimit: z.number().optional().describe('User limit for voice channels'), rateLimitPerUser: z.number().optional().describe('Slowmode in seconds'), position: z.number().optional().describe('Position of the channel'), reason: z.string().optional().describe('Reason for creating the channel'), },
- src/tools/channel-tools.ts:7-14 (helper)channelTypeMap helper object mapping string channel types to Discord.js ChannelType enum values, used in create_channel handler.const channelTypeMap: Record<string, ChannelType> = { text: ChannelType.GuildText, voice: ChannelType.GuildVoice, category: ChannelType.GuildCategory, announcement: ChannelType.GuildAnnouncement, forum: ChannelType.GuildForum, stage: ChannelType.GuildStageVoice, };
- src/index.ts:54-54 (registration)Top-level registration call to registerChannelTools(server), which includes the create_channel tool among channel management tools.registerChannelTools(server);