Skip to main content
Glama
wowjinxy
by wowjinxy

create_invite

Generate invite links for Discord channels with customizable expiration, usage limits, and temporary access options.

Instructions

Create an invite link for a channel.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channel_idYes
max_age_secondsNo
max_usesNo
temporaryNo
uniqueNo
reasonNo

Implementation Reference

  • The handler function `handle_create_invite` that implements the core logic: fetches the target channel, constructs invite parameters (max_age, max_uses, temporary, unique, reason), calls `channel.create_invite()`, and returns the invite URL with details.
    @staticmethod
    async def handle_create_invite(discord_client, arguments: Dict[str, Any]) -> List[TextContent]:
        """Create an invite link"""
        channel = await discord_client.fetch_channel(int(arguments["channel_id"]))
        
        kwargs = {
            "reason": arguments.get("reason", "Invite created via MCP")
        }
        
        if "max_age" in arguments:
            kwargs["max_age"] = arguments["max_age"]
        if "max_uses" in arguments:
            kwargs["max_uses"] = arguments["max_uses"]
        if "temporary" in arguments:
            kwargs["temporary"] = arguments["temporary"]
        if "unique" in arguments:
            kwargs["unique"] = arguments["unique"]
        
        invite = await channel.create_invite(**kwargs)
    
        max_age = kwargs.get("max_age", 0)
        expires_text = "Never" if max_age == 0 else f"{max_age} seconds"
    
        return [TextContent(
            type="text",
            text=(
                f"Created invite for #{channel.name}: {invite.url}\n"
                f"Code: {invite.code}\n"
                f"Expires: {expires_text}"
            )
        )]
  • The input schema definition for the `create_invite` tool within the `list_tools()` function, specifying parameters and validation rules.
    Tool(
        name="create_invite",
        description="Create a custom invite link",
        inputSchema={
            "type": "object",
            "properties": {
                "channel_id": {"type": "string", "description": "Channel ID"},
                "max_age": {"type": "number", "description": "Max age in seconds (0 = never expires)"},
                "max_uses": {"type": "number", "description": "Max uses (0 = unlimited)"},
                "temporary": {"type": "boolean", "description": "Grant temporary membership"},
                "unique": {"type": "boolean", "description": "Create unique invite"},
                "reason": {"type": "string", "description": "Reason for creation"}
            },
            "required": ["channel_id"]
        }
    ),
  • Registration and dispatch logic in `@app.call_tool()`: `create_invite` is listed in `advanced_tool_names` and routed to `AdvancedToolHandlers.handle_create_invite`.
    advanced_tool_names = [
        "edit_server_settings", "create_server_template", "create_channel_category",
        "create_voice_channel", "create_stage_channel", "create_forum_channel",
        "create_announcement_channel", "edit_channel", "set_channel_permissions",
        "create_role", "edit_role", "delete_role", "create_role_hierarchy",
        "create_emoji", "create_webhook", "send_webhook_message",
        "ban_member", "kick_member", "timeout_member", "bulk_delete_messages",
        "create_scheduled_event", "create_invite", "create_thread", "create_automod_rule"
    ]
    
    if name in advanced_tool_names:
        handler_method = f"handle_{name}"
        if hasattr(AdvancedToolHandlers, handler_method):
            return await getattr(AdvancedToolHandlers, handler_method)(discord_client, arguments)

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

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