force_resync
Force a full WhatsApp resync by clearing app state and reconnecting, fixing synchronization issues and refreshing chat data.
Instructions
Force a full WhatsApp resync (clears app state and reconnects).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/auth.ts:68-94 (handler)Tool handler function for 'force_resync' - the MCP tool entry point that calls whatsappService.forceResync() and returns a success/error text result.
async function forceResync( whatsappService: WhatsAppService, ): Promise<CallToolResult> { try { await whatsappService.forceResync(); return { content: [ { type: "text", text: "Resync started. WhatsApp will reconnect and replay history.", }, ], isError: false, }; } catch (error) { log.error("Error forcing resync:", error); return { content: [ { type: "text", text: `Error forcing resync: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } } - src/services/whatsapp.ts:1560-1584 (handler)WhatsAppService.forceResync() - the core implementation that resets app state sync versions, resets account sync counter, destroys and re-initializes the WhatsApp client, then schedules reconnect monitoring.
async forceResync(): Promise<void> { await this.withLifecycleLock(async () => { await this.sync.forceResync(async () => { const sock = this.getSocketOptional(); if (sock?.authState?.keys?.set) { const resetMap: Record<string, null> = {}; for (const name of ALL_WA_PATCH_NAMES) { resetMap[name] = null; } await sock.authState.keys.set({ "app-state-sync-version": resetMap, }); log.info("Force resync: reset app state versions"); } if (sock?.authState?.creds) { sock.authState.creds.accountSyncCounter = 0; sock.ev.emit("creds.update", { accountSyncCounter: 0 }); log.info("Force resync: reset account sync counter"); } }); await this.destroyInternal(); await this.initializeWithinLifecycleLock(); this.ensureReconnectAfterResync(); }); } - src/tools/auth.ts:56-63 (registration)MCP tool registration for 'force_resync' via server.tool(), registering it with empty schema and linking to the forceResync handler function.
server.tool( "force_resync", "Force a full WhatsApp resync (clears app state and reconnects).", {}, async (): Promise<CallToolResult> => { return await forceResync(whatsappService); }, ); - src/server.ts:89-94 (schema)Execution metadata annotation for force_resync in TOOL_EXECUTION_METADATA: readOnly=false, idempotentHint=false, destructiveHint=true, openWorldHint=false.
force_resync: { readOnlyHint: false, idempotentHint: false, destructiveHint: true, openWorldHint: false, }, - src/services/whatsapp-sync.ts:88-91 (helper)WhatsAppSync.forceResync() - helper that sets forcedResync flag and calls the provided resetAppState callback (which resets app state version keys and account sync counter).
async forceResync(resetAppState: () => Promise<void>) { this.forcedResync = true; await resetAppState(); }