Green API WhatsApp

com.green-api由 green-api.com 发布官方发布者v0.1.2更新于 Oct 26, 2026

MCP gateway for WhatsApp via Green API: messaging, contacts, groups and instance management.

已验证Streamable HTTP可网页运行效率与工作流沟通与协作

概览

AI 生成的概览

Green API 的 WhatsApp 网关,让助手通过托管端点收发和管理 WhatsApp 消息、联系人、群组与实例。

可以做什么
  • 发送、转发、编辑和删除 WhatsApp 消息,以及按链接或上传发送文件、位置、联系人和投票
  • 读取聊天记录、最近的收发消息,并将聊天标记为已读
  • 查询联系人、头像、联系人与群组信息,并检测号码是否开通 WhatsApp
  • 创建群组、获取群组数据、添加或移除成员、管理管理员
  • 管理实例:状态、设置、二维码授权、连接、断开、重启、登出,以及合作方层面的创建、列出和删除
  • 从队列轮询或确认接收通知
适用场景
适合需要让助手通过 Green API 操作 WhatsApp 账号的场景,例如回复或发送客户消息、管理群组,或在聊天客户端中监控收到的通知。
运行要求
远程端点 mcp.green-api.com,使用 streamable HTTP。需要 Green API 实例 ID 和 API 令牌,分别通过 X-Instance-Id 和 X-Api-Token 请求头发送。项目也提供自托管的 Go 程序,可用 YAML 或环境变量配置,支持 stdio、SSE 和 HTTP 传输。
安装前请注意
实例 ID 和令牌等于真实 WhatsApp 账号的控制权,两个请求头都应视为机密。许多工具会发送、编辑、删除、转发消息或将消息标记为已读,群组和实例工具会修改或删除数据,包括删除实例。消息内容和联系人会经过 Green API 这一第三方。设置类工具可更改 webhook 和代理配置。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Green API WhatsApp,将其添加到工作区。
  2. 连接 Custom headers 凭据。它们会被私密存储,绝不会在公开页面上展示。
  3. 为需要使用其工具的对话启用该服务。

Web executable,通过 Streamable HTTP。 远程服务在工作区中配置后即可从网页运行时运行。

交给智能体安装

把这段提示词粘贴到 Claude Code、Codex、Cursor 等智能体,或 SourceWeft 对话中。智能体会读取该服务器的安装指南,先向你展示发布者、端点和登录方式,经你同意后再把它添加到你的客户端。密钥不会写进任何命令。

阅读 https://sourceweft.com/mcp/com.green-api%2Fwhatsapp/install.md,并按其中说明把这个 MCP 服务器接入我的客户端。修改任何配置之前,先告诉我它的发布者、端点和登录方式,等我确认。不要把 API 密钥写进命令或我会提交的文件;问我密钥应从哪里获取。

查看智能体所依据的安装指南

其他 MCP 客户端

把它添加到你客户端的 mcpServers 配置中。

{
  "mcpServers": {
    "green-api-whatsapp": {
      "type": "http",
      "url": "https://mcp.green-api.com/mcp",
      "headers": {
        "X-Instance-Id": "<VALUE>",
        "X-Api-Token": "<VALUE>"
      }
    }
  }
}

README

green-api-mcp-gateway

[License: MIT] [Go Version] [release] [Protocol: MCP] [Go Report Card]

Support Links

[Support] [Support] [Support]

Guides & News

[Guides] [News] [News]


MCP gateway for GREEN-API WhatsApp. Lets AI agents (Claude Desktop, OpenClaw, Cursor, and others) send messages, manage instances, and receive notifications via WhatsApp using the Model Context Protocol.

What it does

Send text messages, files by URL, locations, contacts, polls. Forward and edit messages. Manage groups (create, fetch data, add/remove participants). Check phone numbers for WhatsApp, fetch contacts and their info. Get instance state and settings, QR code for authorization. Receive incoming notifications via polling or an HTTP receiver. Partner API for creating/deleting instances. Multi-instance support in a single gateway. Prompt templates for common scenarios (customer support, broadcasts). Prometheus metrics and OpenTelemetry.

Instructions for connecting the MCP server can be found on our website

Architecture

Clean Architecture (Ports & Adapters):

cmd/server/main.go                    — entry point, DI wiringinternal/  domain/                             — business entities, errors, constants (zero dependencies)  application/                        — ports (interfaces)  infrastructure/    auth.go                           — CredentialManager (in-memory credential store)    config/config.go                  — YAML + env configuration    greenapi/client.go                — WhatsApp client via Go SDK    mcp/      server.go                       — MCP server (stdio/sse)      tools.go                        — MCP tools registration      resources.go                    — MCP resources      prompts.go                      — MCP prompts    webhook/      bridge.go                       — polling bridge      receiver.go                     — HTTP receiver

Build

bash
go build -o green-api-mcp-gateway ./cmd/server

Requires Go 1.25+.

Transports & endpoints

The server supports four transports, selected via server.transport (or the GREEN_API_TRANSPORT env var):

TransportEndpoints (relative to host:port)Use case
stdiostdin/stdoutLocal CLIs (Claude Desktop, Cursor) launching the binary.
sseGET / (stream) + POST /messageLegacy MCP clients (SSE only).
httpPOST/GET /mcpStreamable HTTP (MCP 2025-03-26+) — preferred for new clients.
hybrid/sse + /message and /mcp on one portPublic 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 metadata
  • GET /.well-known/oauth-protected-resource — RFC 9728 metadata
  • GET /authorize — browser-facing authorization form
  • POST /token — token exchange

Configuration

Via YAML

yaml
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: text

Via environment variables

Environment variables take precedence over the YAML config:

The variables below cover both deployment modes. Credentials variables (GREEN_API_INSTANCE_ID, GREEN_API_TOKEN, GREEN_API_URL) apply only to local stdio runs with auth.mode: config. For HTTP transports (sse on /sse + /message, http on /mcp, or hybrid) use auth.mode: proxy instead — credentials arrive in HTTP headers or via the built-in OAuth flow and the env credentials are ignored.

  • GREEN_API_INSTANCE_ID — instance ID
  • GREEN_API_TOKEN — API token
  • GREEN_API_URL — API base URL (defaults to https://api.green-api.com)
  • GREEN_API_TRANSPORT — transport: stdio, sse, http, or hybrid
  • GREEN_API_PORT — HTTP port (defaults to 8090)
  • GREEN_API_BASE_URL — public base URL (used for OAuth issuer/redirects, e.g. https://mcp.example.com)
  • GREEN_API_WIDGET_DOMAIN — unique widget origin for ChatGPT Apps submission metadata (defaults to GREEN_API_BASE_URL, then https://mcp.green-api.com)
  • GREEN_API_AUTH_MODE — config or proxy
  • GREEN_API_AUTH_CACHE_TTL — proxy-auth credential cache TTL (seconds)
  • GREEN_API_WEBHOOK_MODE — polling or receiver
  • LOG_LEVEL — log level
  • LOG_FORMAT — text or json

Run

bash
# With environment variablesexport GREEN_API_INSTANCE_ID=1101000001export GREEN_API_TOKEN=your_token./green-api-mcp-gateway
# With a config file./green-api-mcp-gateway --config config.yaml

Integration

Claude Desktop (local stdio)

Add to claude_desktop_config.json:

json
{  "mcpServers": {    "whatsapp": {      "command": "/path/to/green-api-mcp-gateway",      "args": ["--config", "/path/to/config.yaml"]    }  }}

OpenClaw

yaml
mcp:  servers:    - name: whatsapp      command: /path/to/green-api-mcp-gateway      args: ["--config", "/path/to/config.yaml"]

Docker

bash
docker build -t green-api-mcp-gateway .
docker run --rm -i \  -e GREEN_API_INSTANCE_ID=1101000001 \  -e GREEN_API_TOKEN=your_token \  green-api-mcp-gateway

MCP Tools

Messaging

Link to documentation

  • whatsapp_send_message — text message
  • whatsapp_send_file — file by URL
  • whatsapp_send_location — location
  • whatsapp_send_contact — contact (vCard)
  • whatsapp_send_poll — poll
  • whatsapp_forward_messages — forward
  • whatsapp_edit_message — edit
  • whatsapp_delete_message — delete

Instance

Link to documentation

  • whatsapp_get_state — authorization state
  • whatsapp_get_settings — current settings
  • whatsapp_set_settings — update settings
  • whatsapp_get_qr — authorization QR code
  • whatsapp_connect — connect instance
  • whatsapp_disconnect — disconnect instance

Contacts

Link to documentation

  • whatsapp_get_contacts — contact list
  • whatsapp_get_contact_info — contact information
  • whatsapp_check_whatsapp — phone number check

Groups

Link to documentation

  • whatsapp_create_group — create a group
  • whatsapp_get_group_data — group data
  • whatsapp_add_group_participant — add a participant
  • whatsapp_remove_group_participant — remove a participant
  • whatsapp_leave_group — leave a group

Notifications

Link to documentation

  • whatsapp_receive_notification — receive an incoming notification (long-poll)

Partner API

Link to documentation

  • whatsapp_create_instance — create an instance
  • whatsapp_delete_instance — delete an instance
  • whatsapp_get_instances — list instances

MCP Resources

  • whatsapp://instance/{id}/state — instance state
  • whatsapp://instance/{id}/settings — instance settings

MCP Prompts

  • whatsapp_customer_support — template for customer support
  • whatsapp_broadcast — template for broadcast messaging

Dependencies

Development

bash
go test ./...gofmt -w .GOOS=linux GOARCH=amd64 go build -o green-api-mcp-gateway-linux ./cmd/server

License

MIT — see LICENSE.

来源:README.md,提交 23ceece

工具

41

whatsapp_add_group_participant

Add Group Participant

Add a participant to a WhatsApp group

输入参数group_id必填instance_id必填participant_chat_id必填

whatsapp_check_whatsapp

Check WhatsApp Number

Check whether a phone number has a WhatsApp account

输入参数instance_id必填phone_number必填

whatsapp_connect

Connect Instance

Connect a WhatsApp instance. Call this before using other tools. Validates credentials via getStateInstance.

输入参数api_urlapi_token必填instance_id必填

whatsapp_create_group

Create Group

Create a WhatsApp group

输入参数chat_ids必填group_name必填instance_id必填

whatsapp_create_instance

Create Partner Instance

Create a new WhatsApp instance via the GREEN-API Partner API

输入参数partner_token必填

whatsapp_delete_instance

Delete Partner Instance

Delete a WhatsApp instance via the GREEN-API Partner API

输入参数instance_id必填partner_token必填

whatsapp_delete_message

Delete Message

Delete a message

输入参数chat_id必填id_message必填instance_id必填

whatsapp_delete_notification

Delete Notification

Delete a notification from the queue (acknowledge receipt)

输入参数receipt_id必填instance_id必填

whatsapp_disconnect

Disconnect Instance

Disconnect a WhatsApp instance and remove credentials from the session

输入参数instance_id必填

whatsapp_edit_message

Edit Message

Edit a previously sent message

输入参数chat_id必填message必填id_message必填instance_id必填

whatsapp_forward_messages

Forward Messages

Forward messages to another chat

输入参数chat_id必填messages必填instance_id必填chat_id_from必填

whatsapp_get_authorization_code

Get Authorization Code

Get an authorization code for sign-in by phone number

输入参数instance_id必填phone_number必填

whatsapp_get_chat_history

Get Chat History

Get chat message history. Use a small 'count' (default 50, max 100) to keep responses focused.

输入参数countchat_id必填instance_id必填

whatsapp_get_contact_avatar

Get Contact Avatar

Get the avatar of a contact or group

输入参数chat_id必填instance_id必填

whatsapp_get_contact_info

Get Contact Info

Get information about a contact or group

输入参数chat_id必填instance_id必填

whatsapp_get_contacts

Get Contacts

Get the contact list

输入参数instance_id必填

whatsapp_get_group_data

Get Group Data

Get group data (members, name, invite link)

输入参数group_id必填instance_id必填

whatsapp_get_instances

List Partner Instances

List all partner instances via the GREEN-API Partner API

输入参数partner_token必填

whatsapp_get_message

Get Message

Get a message by ID

输入参数chat_id必填id_message必填instance_id必填

whatsapp_get_qr

Get QR Code

Get the QR code for instance authorization. The result contains the QR as an image and a qrLink URL to an official GREEN-API page with a full-size auto-refreshing QR code. Always include the qrLink in your response as a clickable markdown link so the user can open it in the browser and scan comfortably.

输入参数instance_id必填

whatsapp_get_settings

Get Instance Settings

Get instance settings

输入参数instance_id必填

whatsapp_get_state

Get Instance State

Get instance state (authorized, notAuthorized, blocked, sleepMode)

输入参数instance_id必填

whatsapp_get_wa_settings

Get WhatsApp Account Settings

Get WhatsApp account settings (name, description, etc.)

输入参数instance_id必填

whatsapp_last_incoming_messages

Get Recent Incoming Messages

Get recent incoming messages from the last N minutes (default 60, max 1440 = 24 hours).

输入参数minutesinstance_id必填

whatsapp_last_outgoing_messages

Get Recent Outgoing Messages

Get recent outgoing messages from the last N minutes (default 60, max 1440 = 24 hours).

输入参数minutesinstance_id必填

whatsapp_leave_group

Leave Group

Leave a WhatsApp group

输入参数group_id必填instance_id必填

whatsapp_logout

Logout Instance

Log out the WhatsApp instance

输入参数instance_id必填

whatsapp_read_chat

Mark Chat as Read

Mark chat messages as read

输入参数chat_id必填id_messageinstance_id必填

whatsapp_reboot

Reboot Instance

Reboot the WhatsApp instance

输入参数instance_id必填

whatsapp_receive_notification

Receive Notification

Get one notification from the queue (manual polling)

输入参数instance_id必填

whatsapp_remove_group_admin

Demote Group Admin

Revoke admin rights from a group member

输入参数group_id必填instance_id必填participant_chat_id必填

whatsapp_remove_group_participant

Remove Group Participant

Remove a participant from a WhatsApp group

输入参数group_id必填instance_id必填participant_chat_id必填

whatsapp_send_contact

Send Contact

Send a contact card via WhatsApp

输入参数chat_id必填companylast_namefirst_nameinstance_id必填phone_number必填

whatsapp_send_file

Send File by URL

Send a file by URL

输入参数url必填captionchat_id必填file_nameinstance_id必填

whatsapp_send_file_by_upload

Send File

Send a file directly to a chat via multipart upload (no separate URL step)

输入参数captionchat_id必填filename必填file_base64必填instance_id必填

whatsapp_send_location

Send Location

Send a location

输入参数nameaddresschat_id必填latitude必填longitude必填instance_id必填

whatsapp_send_message

Send Message

Send a text message via WhatsApp

输入参数chat_id必填message必填instance_id必填link_previewquoted_message_id

whatsapp_send_poll

Send Poll

Send a poll via WhatsApp

输入参数chat_id必填message必填options必填instance_id必填multiple_answers

whatsapp_set_group_admin

Promote Group Admin

Promote a group member to admin

输入参数group_id必填instance_id必填participant_chat_id必填

whatsapp_set_settings

Update Instance Settings

Update instance settings (webhooks, proxy, etc.)

输入参数instance_id必填webhook_urldelay_messagestate_webhookdevice_webhookincoming_webhookoutgoing_webhookwebhook_url_tokenstatus_instance_webhookmark_incoming_messages_readed

whatsapp_upload_file

Upload File

Upload a file to GREEN-API storage and return its URL. Use the returned URL with whatsapp_send_file.

输入参数filename必填file_base64必填instance_id必填

版本历史

1
  1. v0.1.2最新Sep 16, 2026

评分

已满足适用检查项的 100%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通必需25 分
  • 已声明认证方式必需10 分
  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分