Skip to main content
Glama

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
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
nameYesName of the new channel
typeYesType of channel
parentIdNoID of the parent category
topicNoChannel topic (text channels only)
nsfwNoWhether the channel is NSFW
bitrateNoBitrate for voice channels
userLimitNoUser limit for voice channels
rateLimitPerUserNoSlowmode in seconds
positionNoPosition of the channel
reasonNoReason for creating the channel

Implementation Reference

  • 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) }] }; } );
  • 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) }] };
  • 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'), },
  • 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);

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