MCP gateway for GREEN-API WABA, the official WhatsApp Business API. Lets AI agents (Claude Desktop, ChatGPT, Cursor, OpenClaw and others) send template and session messages, manage message templates and receive notifications from a WhatsApp Business account through the Model Context Protocol.
This is the WABA counterpart of green-api-mcp-gateway. It covers the methods documented in the GREEN-API WABA API.
Send free-form text and files inside the 24-hour customer service window. Send pre-approved message templates at any time. Create, edit, list and delete templates and track their Meta review status. Read account state and settings, chat history and journals. Receive incoming notifications via polling or an HTTP receiver. Multi-instance support in a single gateway. An interactive templates widget for hosts that render MCP Apps. Prometheus metrics and OpenTelemetry.
- 24-hour window. Meta delivers free-form messages (
waba_send_message,waba_send_file) only inside the 24-hour customer service window opened by the customer's last incoming message. Outside it the only option iswaba_send_templatewith an APPROVED template. - Templates need approval.
waba_create_templatesubmits a template to Meta with status PENDING. Pollwaba_get_templatesuntil it is APPROVED before sending it. MARKETING and AUTHENTICATION templates are billed per message; UTILITY templates are cheaper. - Personal chats only. Chat IDs are phone numbers in international format followed by
@c.us, for example11001234567@c.us. Groups are not supported. - No QR code. WABA instances are connected in console.green-api.com; the gateway only reads their state.
Clean Architecture (Ports & Adapters):
cmd/server/main.go — entry point, DI wiring
internal/
domain/ — WABA entities, method names, template values (zero dependencies)
application/ — ports (interfaces)
infrastructure/
auth.go — CredentialManager (in-memory credential store)
auth_proxy.go, oauth.go — proxy auth + OAuth 2.0 PKCE for the hosted server
config/config.go — YAML + env configuration
greenapi/client.go — WABA HTTP client
mcp/
server.go — MCP server (stdio/sse/http/hybrid)
tools.go, tool_names.go — MCP tools registration and names
tool_meta.go — titles, review hints, widget bindings
resources.go — MCP resources and the templates widget
prompts.go, prompt_texts.go — MCP prompts
templates/templates_app.html — templates widget (MCP App)
webhook/
bridge.go — polling bridge
receiver.go — HTTP receiver
go build -o mcp-gateway-waba ./cmd/serverRequires Go 1.25+.
The server supports four transports, selected via server.transport (or the GREEN_API_TRANSPORT env var):
| Transport | Endpoints (relative to host:port) |
Use case |
|---|---|---|
stdio |
stdin/stdout | Local CLIs (Claude Desktop, Cursor) launching the binary. |
sse |
GET / (stream) + POST /message |
Legacy MCP clients (SSE only). |
http |
POST/GET /mcp |
Streamable HTTP (MCP 2025-03-26+) — preferred for new clients. |
hybrid |
/sse + /message and /mcp on one port |
Public server: serves both legacy SSE and Streamable HTTP. |
All HTTP-based transports also expose:
GET /health,GET /healthz— health probes (no auth)GET /favicon.ico,GET /favicon.png— GREEN-API icon
When auth.mode: proxy is enabled, the OAuth 2.0 PKCE endpoints are added too:
GET /.well-known/oauth-authorization-server— RFC 8414 metadataGET /.well-known/oauth-protected-resource— RFC 9728 metadataGET /authorize— browser-facing authorization formPOST /token— token exchange
The hosted public deployment runs in hybrid mode at https://mcp-waba.green-api.com, so clients can connect to either https://mcp-waba.green-api.com/mcp (recommended) or https://mcp-waba.green-api.com/sse (legacy).
server:
transport: stdio # stdio | sse | http | hybrid
port: 8090
auth:
mode: config # config | proxy
cache_ttl: 300 # seconds (proxy mode only)
green_api:
instances:
- id: 1101000001
api_token: "YOUR_TOKEN"
api_url: "https://api.green-api.com"
webhook:
mode: polling
polling_timeout: 20
rate_limit:
requests_per_second: 10
burst: 20
logging:
level: info
format: textSee config/config.example.yaml for every option.
Environment variables take precedence over the YAML config:
GREEN_API_INSTANCE_ID— instance IDGREEN_API_TOKEN— API tokenGREEN_API_URL— API base URL (defaults tohttps://api.green-api.com)GREEN_API_TRANSPORT— transport:stdio,sse,http, orhybridGREEN_API_PORT— HTTP port (defaults to8090)GREEN_API_BASE_URL— public base URL (used for OAuth issuer/redirects, e.g.https://mcp.example.com)GREEN_API_WIDGET_DOMAIN— widget origin for MCP Apps submission metadata (defaults toGREEN_API_BASE_URL)GREEN_API_AUTH_MODE—configorproxyGREEN_API_AUTH_CACHE_TTL— proxy-auth credential cache TTL (seconds)GREEN_API_WEBHOOK_MODE—pollingorreceiverLOG_LEVEL— log levelLOG_FORMAT—textorjson
# With environment variables
export GREEN_API_INSTANCE_ID=1101000001
export GREEN_API_TOKEN=your_token
./mcp-gateway-waba
# With a config file
./mcp-gateway-waba --config config.yamlAdd to claude_desktop_config.json:
{
"mcpServers": {
"waba": {
"command": "/path/to/mcp-gateway-waba",
"args": ["--config", "/path/to/config.yaml"]
}
}
}Point any MCP client that supports Streamable HTTP and OAuth 2.0 at the hosted endpoint:
{
"mcpServers": {
"green-api-waba": {
"url": "https://mcp-waba.green-api.com/mcp"
}
}
}docker build -t mcp-gateway-waba .
docker run --rm -i \
-e GREEN_API_INSTANCE_ID=1101000001 \
-e GREEN_API_TOKEN=your_token \
mcp-gateway-wabawaba_connect— register an instance for the session and validate credentialswaba_disconnect— remove an instance from the session
waba_send_message— free-form text (24-hour window)waba_send_template— pre-approved template with parameters, media header, postbackswaba_send_file— file by URL (24-hour window)waba_send_file_by_upload— file from base64 via multipart upload
waba_get_state— account statewaba_get_settings— notification settingswaba_set_settings— update notification settingswaba_get_wa_settings— account phone and statewaba_reboot— reboot the instance
waba_create_template— create and submit a template to Metawaba_edit_template— edit a REJECTED, APPROVED or PAUSED templatewaba_get_templates— list templates, optional status filterwaba_get_template— one template by IDwaba_delete_template— delete by element namewaba_delete_template_by_id— delete one version by ID
waba_receive_notification— take one notification from the queuewaba_delete_notification— acknowledge a notification
waba_get_chat_history— chat historywaba_get_message— one message by IDwaba_last_incoming_messages— recent incoming messageswaba_last_outgoing_messages— recent outgoing messages
waba_show_messages_queue— pending outgoing messageswaba_clear_messages_queue— drop the outgoing queue
These require a partner_token from the GREEN-API partner dashboard, separate from any instance's own credentials.
waba_create_instance— create a new instancewaba_delete_instance— delete an instance. Params:partner_token,instance_idwaba_get_instances— list all instances under the partner account
waba_service_method— call a GREEN-API method by name. See the method reference.
waba://instance/{id}/state— account statewaba://instance/{id}/settings— notification settingswaba://instance/{id}/templates— all templates with statusui://templates— interactive templates widget (MCP App), rendered forwaba_get_templates
waba_customer_support— support agent prompt with the 24-hour window ruleswaba_template_broadcast— plan and run a template broadcast
- mcp-go — MCP SDK
- GREEN-API WABA API — HTTP API reference
go mod tidy
go build ./...
go test ./...
gofmt -w .
GOOS=linux GOARCH=amd64 go build -o mcp-gateway-waba-linux ./cmd/serverMIT — see LICENSE.