Skip to main content
Glama
scarecr0w12

discord-mcp

create_invite

Generate Discord server invites for channels with customizable expiration, usage limits, and membership settings to manage access control.

Instructions

Create an invite for a channel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
channelIdYesThe ID of the channel
maxAgeNoMax age in seconds (0 = never, default 86400)
maxUsesNoMax uses (0 = unlimited, default 0)
temporaryNoGrant temporary membership (default false)
uniqueNoCreate a unique invite (default false)
reasonNoReason for creating

Implementation Reference

  • The handler function implementing the core logic of the 'create_invite' tool. It fetches the guild and channel, validates the channel type, creates the invite using Discord.js API, and returns the invite details or error.
    async ({ guildId, channelId, maxAge, maxUses, temporary, unique, 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) throw new Error('Channel not found');
    
        // Check if channel type supports invites
        if (channel.type === ChannelType.GuildCategory) {
          throw new Error('Cannot create invite for category channels');
        }
    
        const invitableChannel = channel as InvitableChannel;
        const invite = await invitableChannel.createInvite({
          maxAge,
          maxUses,
          temporary,
          unique,
          reason,
        });
    
        return {
          code: invite.code,
          url: invite.url,
          channelId: invite.channelId,
          maxAge: invite.maxAge,
          maxUses: invite.maxUses,
          temporary: invite.temporary,
          expiresAt: invite.expiresAt?.toISOString(),
          message: 'Invite 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 schema defining the input parameters for the 'create_invite' tool, including guildId, channelId, and optional invite options.
    {
      guildId: z.string().describe('The ID of the server (guild)'),
      channelId: z.string().describe('The ID of the channel'),
      maxAge: z.number().optional().describe('Max age in seconds (0 = never, default 86400)'),
      maxUses: z.number().optional().describe('Max uses (0 = unlimited, default 0)'),
      temporary: z.boolean().optional().describe('Grant temporary membership (default false)'),
      unique: z.boolean().optional().describe('Create a unique invite (default false)'),
      reason: z.string().optional().describe('Reason for creating'),
    },
  • The registration of the 'create_invite' tool with the MCP server using server.tool(), including name, description, input schema, and handler function.
    server.tool(
      'create_invite',
      'Create an invite for a channel',
      {
        guildId: z.string().describe('The ID of the server (guild)'),
        channelId: z.string().describe('The ID of the channel'),
        maxAge: z.number().optional().describe('Max age in seconds (0 = never, default 86400)'),
        maxUses: z.number().optional().describe('Max uses (0 = unlimited, default 0)'),
        temporary: z.boolean().optional().describe('Grant temporary membership (default false)'),
        unique: z.boolean().optional().describe('Create a unique invite (default false)'),
        reason: z.string().optional().describe('Reason for creating'),
      },
      async ({ guildId, channelId, maxAge, maxUses, temporary, unique, 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) throw new Error('Channel not found');
    
          // Check if channel type supports invites
          if (channel.type === ChannelType.GuildCategory) {
            throw new Error('Cannot create invite for category channels');
          }
    
          const invitableChannel = channel as InvitableChannel;
          const invite = await invitableChannel.createInvite({
            maxAge,
            maxUses,
            temporary,
            unique,
            reason,
          });
    
          return {
            code: invite.code,
            url: invite.url,
            channelId: invite.channelId,
            maxAge: invite.maxAge,
            maxUses: invite.maxUses,
            temporary: invite.temporary,
            expiresAt: invite.expiresAt?.toISOString(),
            message: 'Invite 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:62-62 (registration)
    Call to registerInviteTools which includes the 'create_invite' tool among other invite tools.
    registerInviteTools(server);
  • Type definition for channels that support invites, used in the create_invite handler.
    type InvitableChannel = TextChannel | VoiceChannel | StageChannel | NewsChannel;
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('Create an invite') but doesn't explain what this entails—such as whether it requires admin permissions, how invites are generated, what the output looks like, or any rate limits. This leaves significant gaps for a mutation tool with no structured safety hints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without any fluff or redundancy. It is front-loaded and wastes no words, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that this is a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't cover behavioral aspects like permissions, side effects, or response format, which are crucial for safe and effective use. The high schema coverage helps with parameters but doesn't compensate for the lack of operational context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so all parameters are documented in the schema with clear descriptions (e.g., 'maxAge' as 'Max age in seconds'). The description adds no additional parameter semantics beyond what the schema provides, which is adequate but not additive, meeting the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create an invite') and the target resource ('for a channel'), which is specific and unambiguous. However, it doesn't differentiate from sibling tools like 'list_invites' or 'delete_invite', which would require explicit comparison for a score of 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'list_invites' or 'delete_invite', nor does it mention prerequisites such as required permissions or context. It lacks any usage context or exclusions, leaving the agent to infer based on the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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