get_invite_info
Retrieve details about a Discord invite code to verify its validity and view server information before joining.
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 'get_invite_info' tool logic. It uses the Discord client to fetch invite details, formats the response data, handles errors with withErrorHandling, and returns JSON-formatted content or error message.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:53-55 (schema)Zod schema defining the input parameters for the 'get_invite_info' tool: a required 'inviteCode' string.{ inviteCode: z.string().describe('The invite code (without discord.gg/)'), },
- src/tools/invite-tools.ts:50-85 (registration)Registers the 'get_invite_info' tool with the MCP server, including 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:61-61 (registration)Invokes registerInviteTools to register the invite tools module (including get_invite_info) to the main MCP server instance.registerInviteTools(server);