Choose the extension point
Consider a Go service that maintains a reading list for a group chat. It needs to know when a message has been saved and when someone edits a suggestion. WA MCP already owns the WhatsApp connection and the local message store. Its public Go package lets a service observe committed changes and use the bridge's existing configuration. A separate Python process can still expose the stored history to an MCP client.
Import github.com/tsahospital-beep/wa-mcp/bridge/pkg/wabridge. The bridge command itself calls this package. The underlying WhatsApp Go library is whatsmeow. Working through the public package gives your program the bridge's storage, login and configuration behavior. Keep imports inside the published package boundary so changes to the bridge's internal packages do not become changes your application has to track.
Start the bridge with your program
Use wabridge.Main when the program should accept the same command-line arguments as the bridge. It returns an exit status for your main function. An application that already manages its own lifetime can use Run(ctx, opts) and cancel the context during shutdown. Use a single running owner for a linked-device session.
package main
import (
"os"
"github.com/tsahospital-beep/wa-mcp/bridge/pkg/wabridge"
)
func main() {
opts := wabridge.Options{Version: "reading-list-1"}
os.Exit(wabridge.Main(os.Args[1:], opts))
}
During local development the embedding guide shows how to point a Go module's replace directive at the bridge checkout. This lets you build the application and bridge from the same source tree. Set the configuration path explicitly so launching from a service manager or another directory still finds the expected store. The version string also appears in the status response and helps identify which program owns the listener.
Observe a message after it is stored
Set OnMessageStored to a function that accepts a context and a stored message. Inspect the origin before deciding what to do. A live update can be an outgoing message sent on your phone. A history update can describe something said long before your application started. For a notification about a new suggestion, inspect both the origin and the outgoing flag and match the intended chat.
For a reading list that tracks corrections, record the message and chat identifiers. An edit carries the revised body and an edit time. A recorded deletion can still carry the old body, so look at the deletion fields before displaying a suggestion. Bulk chat export imports skip the message hook. If the application needs to build an initial index, read the store as a separate step.
Hooks run on the goroutine that wrote the row. Keep the work there short. A hook sees plaintext even with field encryption active. Logging message bodies or copying them to another database creates another place where the content must be protected. A count grouped by message kind may be sufficient when testing the connection.
Add a route and test it locally
The routes callback receives a router and the running bridge's dependencies. Register an application-specific path with Handle to use the bridge's token checks. The bridge reserves its root, health endpoint and API namespace. A route that lists the most recent suggestion can ask the provided store for messages with a chat identifier and a small limit.
Test the handler before using the live group. The package provides RoutesHandler, which builds an HTTP handler with the bridge's token, host and body checks. Supply fake dependencies and a test token. Exercise an empty chat and one with a single message so the HTTP response for each case is clear. No phone pairing is needed for that handler test.
Expose a result to an assistant
The standard Python MCP server can read the configured WhatsApp store alongside your Go program. Keep the config and the relevant storage key available to that process. If you already run a Python FastMCP application, the project also provides wa_mcp_server.embed.register to add selected tools and rename them to avoid a collision. Choose only the tools the assistant needs for the reading list.
A local HTTP route you register in Go remains your application's route. To make a new reading-list operation available as an MCP tool, define that tool in the client-facing server and give it a clear input and result. Ordinary message lookup can use the existing tools. This distinction lets you test phone sync, the Go route and the assistant's tool list independently.
Questions
Which WhatsApp Go library does the MCP bridge use?
The bridge uses whatsmeow for the WhatsApp connection. Import pkg/wabridge to extend WA MCP with stored-message hooks and HTTP routes. The Python MCP server handles client tool calls.
Will an import call my Go message hook?
Bulk chat export imports skip OnMessageStored. Read existing rows when building an initial index, then process the live, history and change origins your application needs.