create_invite
Generate invite links for Discord channels with customizable expiration, usage limits, and access controls to manage community invitations.
Instructions
Create an invite link for a channel.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel_id | Yes | ||
| max_age_seconds | No | ||
| max_uses | No | ||
| temporary | No | ||
| unique | No | ||
| reason | No |
Implementation Reference
- The core handler function that implements the `create_invite` tool. It fetches the specified channel, constructs invite parameters from arguments (max_age, max_uses, temporary, unique, reason), calls channel.create_invite(), and returns a TextContent with the invite URL, code, and expiration info.@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}" ) )]
- src/discord_mcp/integrated_server.py:494-509 (registration)The tool registration in the list_tools() function, defining the name, description, and input schema for `create_invite`.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"] } ),
- src/discord_mcp/integrated_server.py:1005-1019 (registration)The dispatcher routing logic in call_tool() that recognizes `create_invite` as an advanced tool and dynamically invokes `AdvancedToolHandlers.handle_create_invite(discord_client, arguments)`.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)