Fetch Invite Code
fetch_invite_codeRetrieve the invite code or link for a WhatsApp group using its JID. Use to obtain group invitation from the connected instance.
Instructions
Fetch the invite code/link for a WhatsApp group via the pinned instance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| groupJid | Yes | Group JID (e.g. 120363000000000000@g.us) |
Implementation Reference
- src/tools/fetch-invite-code.ts:6-8 (schema)Input schema for fetch_invite_code: requires a groupJid string parameter.
const schema = { groupJid: z.string().min(1).describe("Group JID (e.g. 120363000000000000@g.us)"), }; - src/tools/fetch-invite-code.ts:10-30 (handler)Handler function that registers the 'fetch_invite_code' tool. Makes a GET request to /group/inviteCode/{instanceName}?groupJid={groupJid} and returns the invite code data.
export function registerFetchInviteCode(server: McpServer, client: EvolutionClient): void { server.registerTool( "fetch_invite_code", { title: "Fetch Invite Code", description: "Fetch the invite code/link for a WhatsApp group via the pinned instance.", inputSchema: schema, }, async (args) => { try { const data = await client.get( `/group/inviteCode/${client.instanceName}?groupJid=${encodeURIComponent(args.groupJid)}` ); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } catch (e) { if (e instanceof McpError) return { isError: true, content: [{ type: "text" as const, text: e.message }] }; throw e; } } ); } - src/tools/index.ts:48-48 (registration)Import of registerFetchInviteCode from the fetch-invite-code module.
import { registerFetchInviteCode } from "./fetch-invite-code.js"; - src/tools/index.ts:121-121 (registration)Registration call for the fetch_invite_code tool in the central tools index.
registerFetchInviteCode(server, client); - src/evolution-client.ts:20-22 (helper)The EvolutionClient.get() method used by the handler to make the HTTP GET request to the Evolution API.
async get<T = unknown>(path: string): Promise<T> { return this.request<T>("GET", path); }