list_invites
Retrieve all active Discord server invites by providing the guild ID to manage and monitor invitation links.
Instructions
List all invites in a server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) |
Implementation Reference
- src/tools/invite-tools.ts:11-47 (handler)Core handler implementation for the 'list_invites' tool. Registers the tool with MCP server, defines input schema (guildId), fetches all invites from the specified Discord guild, maps them to a structured format, handles errors with withErrorHandling, and returns JSON stringified response.server.tool( 'list_invites', 'List all invites in a server', { guildId: z.string().describe('The ID of the server (guild)'), }, async ({ guildId }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guild = await client.guilds.fetch(guildId); const invites = await guild.invites.fetch(); return invites.map((invite) => ({ code: invite.code, url: invite.url, channelId: invite.channelId, channelName: invite.channel?.name, inviterId: invite.inviterId, inviterUsername: invite.inviter?.username, uses: invite.uses, maxUses: invite.maxUses, maxAge: invite.maxAge, temporary: invite.temporary, createdAt: invite.createdAt?.toISOString(), expiresAt: invite.expiresAt?.toISOString(), targetType: invite.targetType, targetUserId: invite.targetUser?.id, })); }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } );
- src/tools/invite-tools.ts:14-16 (schema)Input schema for list_invites tool using Zod: requires guildId as string.{ guildId: z.string().describe('The ID of the server (guild)'), },
- src/index.ts:61-61 (registration)Registration of invite tools (including list_invites) by calling registerInviteTools(server) in the MCP server setup.registerInviteTools(server);
- src/index.ts:19-19 (registration)Import of registerInviteTools function that contains the list_invites tool registration.import { registerInviteTools } from './tools/invite-tools.js';