get_invite_info
Retrieve detailed information about a Discord invite using its code, including server details and usage statistics.
Instructions
Get information about a specific invite
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inviteCode | Yes | The invite code (without discord.gg/) |
Implementation Reference
- src/tools/invite-tools.ts:56-84 (handler)The handler function that executes the tool logic: fetches Discord invite info using client.fetchInvite(inviteCode), structures the data (guild, channel, inviter, counts, etc.), handles errors with withErrorHandling, and returns JSON response.async ({ inviteCode }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const invite = await client.fetchInvite(inviteCode); return { code: invite.code, url: invite.url, guildId: invite.guild?.id, guildName: invite.guild?.name, guildDescription: invite.guild?.description, channelId: invite.channelId, channelName: invite.channel?.name, channelType: invite.channel?.type, inviterId: invite.inviterId, inviterUsername: invite.inviter?.username, approximateMemberCount: invite.memberCount, approximatePresenceCount: invite.presenceCount, expiresAt: invite.expiresAt?.toISOString(), targetType: invite.targetType, }; }); 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:54-55 (schema)Input schema defined with Zod: requires 'inviteCode' as a string describing the invite code without the discord.gg/ prefix.inviteCode: z.string().describe('The invite code (without discord.gg/)'), },
- src/tools/invite-tools.ts:50-85 (registration)Registers the 'get_invite_info' tool on the MCP server, specifying name, description, input schema, and handler function.server.tool( 'get_invite_info', 'Get information about a specific invite', { inviteCode: z.string().describe('The invite code (without discord.gg/)'), }, async ({ inviteCode }) => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const invite = await client.fetchInvite(inviteCode); return { code: invite.code, url: invite.url, guildId: invite.guild?.id, guildName: invite.guild?.name, guildDescription: invite.guild?.description, channelId: invite.channelId, channelName: invite.channel?.name, channelType: invite.channel?.type, inviterId: invite.inviterId, inviterUsername: invite.inviter?.username, approximateMemberCount: invite.memberCount, approximatePresenceCount: invite.presenceCount, expiresAt: invite.expiresAt?.toISOString(), targetType: invite.targetType, }; }); 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)Calls registerInviteTools(server) in the main MCP server setup, which registers the get_invite_info tool along with other invite management tools.registerInviteTools(server);
- src/index.ts:19-19 (registration)Imports the registerInviteTools function used to register invite tools including get_invite_info.import { registerInviteTools } from './tools/invite-tools.js';