Skip to main content
Glama

force_resync

Destructive

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

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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,
        };
      }
    }
  • 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();
      });
    }
  • 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);
      },
    );
  • 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,
    },
  • 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();
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations flag destructiveHint: true; description adds that it clears app state and reconnects, explaining the destructive action. No contradictions. Provides useful context beyond annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, front-loaded with the key action, no unnecessary words. Every part contributes to understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Simple destructive tool with no output schema. Description covers the core action but does not explain what happens after (e.g., success response, side effects like temporary disconnection). Adequate but leaves minor gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

No parameters, so schema coverage is 100%. Description adds no param info, but baseline score is 4 per instructions for zero-parameter tools.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states action (force resync), resource (WhatsApp), and what it does (clears app state and reconnects). No sibling tool performs resync, so it is distinct.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like check_auth_status or logout. Context implies it is for resetting a stuck connection, but no explicit conditions or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/loglux/whatsapp-mcp-stream'

If you have feedback or need assistance with the MCP directory API, please join our Discord server