discord_create_text_channel
Create a new text channel in a Discord server to organize conversations, with an optional topic for context.
Instructions
Creates a new text channel in a Discord server with an optional topic
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | ||
| channelName | Yes | ||
| topic | No |
Implementation Reference
- src/tools/channel.ts:144-197 (handler)The main handler function that executes the discord_create_text_channel tool. It validates input with CreateTextChannelSchema, fetches the guild, creates a text channel using guild.channels.create(), and returns success or error response.export async function createTextChannelHandler( args: unknown, context: ToolContext ): Promise<ToolResponse> { const { guildId, channelName, topic, reason } = CreateTextChannelSchema.parse(args); try { if (!context.client.isReady()) { return { content: [{ type: 'text', text: 'Discord client not logged in.' }], isError: true, }; } const guild = await context.client.guilds.fetch(guildId); if (!guild) { return { content: [ { type: 'text', text: `Cannot find guild with ID: ${guildId}` }, ], isError: true, }; } // Create the text channel const channelOptions: { name: string; type: ChannelType.GuildText; topic?: string; reason?: string; } = { name: channelName, type: ChannelType.GuildText, }; if (topic !== undefined) { channelOptions.topic = topic; } if (reason !== undefined) { channelOptions.reason = reason; } const channel = await guild.channels.create(channelOptions); return { content: [ { type: 'text', text: `Successfully created text channel "${channelName}" with ID: ${channel.id}`, }, ], }; } catch (error) { return handleDiscordError(error); } }
- src/tool-list.ts:118-131 (schema)MCP tool schema definition for discord_create_text_channel, including name, description, and inputSchema used for tool listing and validation.{ name: 'discord_create_text_channel', description: 'Creates a new text channel in a Discord server with an optional topic', inputSchema: { type: 'object', properties: { guildId: { type: 'string' }, channelName: { type: 'string' }, topic: { type: 'string' }, }, required: ['guildId', 'channelName'], }, },
- src/server.ts:138-144 (registration)Registration and dispatch in the main server switch statement, calling createTextChannelHandler for the tool execution.case 'discord_create_text_channel': this.logClientState('before discord_create_text_channel handler'); toolResponse = await createTextChannelHandler( args, this.toolContext ); return toolResponse;
- src/transport.ts:337-342 (registration)Additional registration in the HTTP transport handler switch for direct method calls.case 'discord_create_text_channel': result = await createTextChannelHandler( params, this.toolContext! ); break;
- src/tools/tools.ts:1-11 (helper)Re-export of createTextChannelHandler from channel.ts, used by server.ts and transport.ts imports.export { createCategoryHandler, createTextChannelHandler, deleteCategoryHandler, deleteChannelHandler, editCategoryHandler, getServerInfoHandler, readMessagesHandler, } from './channel.js'; export { createForumPostHandler,