How I built a WhatsApp MCP server that paces itself like a person
A WhatsApp reply can have several outcomes before anyone receives it. I can decide to leave it as a draft. My client can ask me to check the recipient. The bridge can notice that I have already sent the same text. If I s
A WhatsApp reply can have several outcomes before anyone receives it. I can decide to leave it as a draft. My client can ask me to check the recipient. The bridge can notice that I have already sent the same text. If I set quiet hours, the reply might be due in the morning. I wanted my MCP server to preserve those distinctions. A tool that reports success whenever it accepts a request leaves me guessing what the other person actually saw.
I built WA MCP as two processes. A Go bridge uses whatsmeow to link to an account and maintain a local SQLite store. A Python MCP server reads that store and calls the bridge API. That lets me ask a client to find an old message while giving the bridge a single place to decide whether a new message can go out. It also means that closing my assistant does not cancel something I explicitly scheduled for later.
Start with a question that needs no reply
My starting example is "What are my tasks today?" The tool behind it, my_day, collects open requests, promises that are due, chats waiting for a reply, missed calls and scheduled sends. It can return those items using plain rules. The assistant can put the result into words. There is no need to enable sending, turn on a background model or mark the source messages as read.
The same separation applies to ordinary search. I can search message bodies and locally stored transcripts from Python. If the phone has supplied only recent history, the search covers what is in the store. I can ask the phone for an older page or import a WhatsApp chat export. I keep imported messages out of the daily task list by default. An old request turning up in search is useful. An assistant telling me that the same request needs my attention today is a different claim.
Put the switch where the message leaves
Sending starts off. Here is the beginning of the send method in the Go bridge.
func (s *Sender) Send(ctx context.Context, req Request) (Result, error) {
if !s.Cfg.Enabled {
return Result{}, ErrDisabled
}
That check also matters for people who never use MCP. The bridge has an HTTP API and the Python SDK can use it directly. With sending disabled, the API refuses send and schedule requests, and scheduled messages stay pending. An assistant prompt telling a model to be careful would do nothing for a script that called the API on its own. Send method
Once sending is enabled, approval depends on the path the request takes. With the default confirmation setting and a client that supports MCP elicitation, the server asks the person using the client. It can show the address, where the name came from, the full text and the number of parts. If two address-book names match, the tool returns candidates. It does not choose whichever one happens to come first.
A client that cannot ask the question normally stops there. An owner can enable a confirmation flag instead. The model itself can set that flag, so the owner gives up the assurance that someone saw the request. The HTTP API has no interactive approval step at all. When I describe an approval dialog, I specify the client path. Someone deciding where to keep the bridge token needs to know what possession of that token allows.
Reserve room before waiting
Imagine that two requests arrive when there is room for only one more message in the hourly limit. If each request reads the count, waits and records its send afterward, both can see that last slot. A typing delay would make the race last longer. The bridge checks for duplicates and reserves capacity before doing the part the recipient can see.
resv, err := s.reserve(ctx, target, hash, now, len(parts))
if err != nil {
return Result{}, err
}
defer resv.releaseUnused(context.WithoutCancel(ctx), s.DB)
The unit here is a message part. A long reply can cross a WhatsApp message boundary, even when the user approves the whole thing in one dialog. The bridge accounts for the planned parts up front. A partial failure can return the IDs of the parts that went out. That gives the caller something more specific to work with than an error next to an apparently unsent paragraph. Reservation and send path
The counters live in the database and survive a restart. Duplicate protection also needs enough information to recognize a repeat, but saving another copy of everyone's outgoing text would be a poor trade. The duplicate check uses a keyed hash. From the caller's side a duplicate and an exhausted limit have different results. A duplicate gets HTTP 409. A limit gets HTTP 429. Waiting for an empty queue and pressing send again would be the wrong response to several of these outcomes.
Give the pause a meaning
For an ordinary reply, the bridge can mark recent unread incoming messages in the chat as read before it sends. Imported messages are excluded. Read receipts have their own permission because opening a search result is a different action from showing the other person that I have read their message.
With pacing on, the bridge leaves space after a recent send to the same chat and shows a typing indicator for a duration based on the length of the reply. The finished text goes out as a message part. The recipient never receives a stream of individual letters. A voice note uses a recording indicator. The API reports the time spent waiting in waited_ms, which helps a caller explain why an approved send took time. Turning these waits off still leaves quiet hours, duplicate protection and limits in effect.
One small part of the implementation makes the wait cancellable. This is the actual wait inside realSleep.
t := time.NewTimer(d)
defer t.Stop()
select {
case <-t.C:
return nil
case <-ctx.Done():
return ctx.Err()
}
There are two ways out of that wait, and only one of them means the timer finished. Together with releasing unused reservations, that distinction matters when a client disappears during a reply. Pacing implementation
Let morning mean morning
The sending guide has this example for a bridge that should defer ordinary replies overnight.
{
"sending": {
"quiet_hours": { "enabled": true, "start": "22:00", "end": "08:00", "action": "queue" }
}
}
Those times belong to the machine running the bridge. If I move the bridge to a server, its time zone is part of my configuration. A queued request returns a schedule ID. I can inspect it among the pending sends, or cancel it. An owner who wants a failed request during that period can choose refusal instead. Neither outcome should put a "message delivered" line in a conversation. Quiet hours and scheduling
The difficult boundary for a scheduler is a process stopping between sending something and recording the outcome. On restart, a one-time entry interrupted in the sending state is marked failed. It may already have reached the recipient. A recurring entry can skip that interrupted run and retain its schedule. I would rather see a failed birthday reminder that needs checking than have the bridge silently repeat a message whose delivery it cannot establish.
What I would check before linking a phone
The login preview uses fake codes, so I can see the window before connecting an account. For a live setup I would first ask the client for bridge_status, leave sending off and read one result. The store encrypts message text and transcripts by default. Downloads, exports, chat identifiers, titles and timestamps fall outside that field encryption. A hosted assistant still receives the tool results it asks for. Choosing a local bridge is only one part of choosing who sees a conversation.
WA MCP uses the unofficial WhatsApp Web protocol. WhatsApp can change it, restrict an account or ban it. I have no guarantee to offer about that. The reason to use a pause is that I want a reply to respect the pace and quiet hours I chose. The reason to keep the off switch is that quite a lot of what I want from my chats only requires reading them. Project and quick start and security guide
Site with setup guides: https://tsahospital-beep.github.io/wa-mcp/ . If it is useful to you, a star on GitHub helps other people find it.
Writing disclosure: AI drafted this article from the project documentation and source excerpts.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.