AI Agents

Scaling AI Agent Fleets with Model Context Protocol

WhatsMCP Engineering
Oct 2, 2024 · 6 min read

An architectural walkthrough on exposing WhatsApp thread history and tools natively to Claude and custom agent runtimes securely.

Why Thread History Is the Hard Part

Most MCP integrations start with tool calls and treat conversation state as an afterthought. For a WhatsApp agent that's backwards: one that can send a message but can't see the last twenty exchanges in a thread will re-ask questions a human already answered. Every read path is scoped to a single API key's own accounts from the first line of the handler, not filtered after the fact.

Cursor-Based Polling, Not Webhooks-Only

Agent runtimes reconnect, restart, and occasionally crash mid-session. A push-only design loses whatever arrived while the runtime was down. Every message-list call instead returns a cursor, and an agent — or its host runtime — resumes from exactly where it left off:

  • No gap and no duplicate delivery, even for two messages that land in the same millisecond.
  • A crashed runtime catches up by replaying from its last known cursor instead of missing a window of history.
  • Webhooks remain available as a push hint, but the cursor is the source of truth an agent can always fall back to.

Technical note: an agent runtime that never persists its cursor re-reads from the beginning on every restart. Persist it, or accept the replay cost.

What We'd Do Differently

We under-documented the persistence requirement in the first release of the tool surface, and it is the single most common support question fleet operators ask.

About WhatsMCP Engineering

Engineering Team at WhatsMCP. The team building WhatsMCP's MCP server and SIP bridge — the people who wrote the code these posts describe.

Related posts

Infrastructure
Sep 19, 2024

Anti-Block Safeguards: Rate Limiting & Egress IP Rotation

Configuration
Sep 5, 2024

PJSIP Configuration & Codec Transcoding Secrets