Skip to main content
Glama

discord_create_text_channel

Create a new text channel in a Discord server, specifying the channel name and optional topic, to organize conversations effectively.

Instructions

Creates a new text channel in a Discord server with an optional topic

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelNameYes
guildIdYes
topicNo

Implementation Reference

  • The main handler function that parses arguments using CreateTextChannelSchema and creates a new Discord text channel using guild.channels.create with optional topic and reason.
    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: any = {
          name: channelName,
          type: ChannelType.GuildText
        };
        if (topic) channelOptions.topic = topic;
        if (reason) 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);
      }
    }
  • MCP tool schema definition including name, description, and input schema for discord_create_text_channel.
    {
      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:123-126 (registration)
    Switch case registration in the main server handler that dispatches to createTextChannelHandler.
    case "discord_create_text_channel":
      this.logClientState("before discord_create_text_channel handler");
      toolResponse = await createTextChannelHandler(args, this.toolContext);
      return toolResponse;
  • Zod validation schema used by the handler to parse input arguments.
    export const CreateTextChannelSchema = z.object({
        guildId: z.string(),
        channelName: z.string(),
        topic: z.string().optional(),
        reason: z.string().optional()
    });

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

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