zalo-mcp
Enables AI agents to automate Zalo Personal & Official Accounts, including sending messages, managing conversations, and handling authentication.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
zalo-mcp
Gói cài đặt độc lập Model Context Protocol (MCP) server và CLI wrapper cho Zalo. Cho phép cài đặt toàn cục qua npm hoặc triển khai trong môi trường đóng gói (sandbox) 1-click giúp AI agents (Claude Code, Cursor) tự động hóa Zalo Personal & Official Account mà không làm rác máy tính của bạn. Cả hai cách cài đặt đều cung cấp lệnh zalo-mcp trực tiếp trên terminal.
Sự khác biệt giữa zalo-mcp và zalo-agent-cli?
zalo-agent-cli: Là bộ mã nguồn lõi (engine). Xử lý toàn bộ logic API, login, và chứa mã nguồn thật sự của MCP Server.zalo-mcp(Repo này): Là vỏ bọc triển khai nhanh (deployment & CLI wrapper). Nó không chứa mã nguồn lõi mà chuyển tiếp toàn bộ lệnh CLI và khởi chạy MCP Server từ@ardennguyen/zalo-agent-cli. Dù bạn cài toàn cục (npm i -g @ardennguyen/zalo-mcp) hay dùng script 1-click tạo thư mục biệt lập (tự độngnpm linkvà cấu hình.env), bạn đều có thể chạy lệnhzalo-mcpở bất kỳ đâu.
📋 Yêu cầu hệ thống
Trước khi cài đặt, hãy đảm bảo máy bạn đã có:
Node.js: Phiên bản 22.19 trở lên (Bắt buộc cho MCP server và CLI; engine 3.0 yêu cầu
>=22.19.0).Git: Cần thiết để clone các bản cập nhật phụ thuộc.
@ardennguyen/zalo-agent-cli:zalo-mcp2.1.0 cần engine3.0.0trở lên (^3.0.0; gói tự cài đúng phiên bản). Engine 3.0.0 chạy trên lớp giao thức Zalo riêng (không còn zca-js), và cung cấp 37 MCP tool: mọi lệnh CLI đều có một thao tác MCP, kể cả các lệnh Official Account, ZBS và Social quazalo_official. Tool và cờ mới của engine chỉ dùng được quazalo-mcpsau khi bạn cập nhật (.\zalo-mcp.ps1 update/./zalo-mcp.sh update, hoặcnpm install -g @ardennguyen/zalo-mcp@latestnếu cài toàn cục). Các wrapper 2.0.5–2.0.9 chạy engine 2.5.x. Lịch sử phiên bản: CHANGELOG.md.
Engine 3.0 đã đổi hợp đồng MCP. Client viết cho 2.x cần đổi theo:
Mỗi id một tên: tin nhắn là
msgId(không cònidhaymessageId), người dùng làuserId(không cònuid), người gửi một tin làsenderId.zalo_view_medianhậnmsgId,zalo_delete_messagenhậnsenderId.threadTypelà"dm"hoặc"group"ở cả đầu vào lẫn kết quả; số bị từ chối.Mọi id là chuỗi, kể cả id nhỏ.
Thao tác phá hủy được hỏi trước.
zalo_undo,zalo_delete_message,zalo_groupleave, … cầnconfirm: true(dryRun: trueđể xem trước).confirmModetrongmcp-config.json(hoặcZALO_MCP_CONFIRM_MODE) quyết định ai xác nhận:agent(mặc định; lần đầu gặp thao tác được bảo vệ, agent được dặn hỏi bạn muốn xử lý thế nào),human(server tự hỏi bạn: qua MCP elicitation với stdio, còn lại bằng một trang phê duyệt dùng một lần có link trong kết quả, dùng được cả qua HTTP) hoặcoff.Các tool mới,
zalo_friend,zalo_groupvàzalo_send_messagetừ chối tham số không nhận thay vì bỏ qua.
Engine 3.0 còn đổi cách nó chạy:
Một phiên đăng nhập web cho mỗi tài khoản. Server chính là phiên web đó: đăng nhập QR vào Zalo trên trình duyệt bằng cùng tài khoản sẽ đăng xuất server. Điện thoại và ứng dụng Zalo trên máy tính là các phiên riêng, chạy song song được. Hãy đọc và trả lời trên điện thoại hoặc ứng dụng máy tính bên cạnh server, không mở tài khoản trên trình duyệt.
Dữ liệu được mã hóa khi lưu: phiên đăng nhập, cơ sở dữ liệu tin nhắn
zalo.dbvà media được niêm phong bằng khóa của từng tài khoản (DPAPI trên Windows, keychain trên macOS, passphrase trên VPS). Lệnh 3.0 đầu tiên chuyển dữ liệu cũ ngay tại chỗ, không giữ bản rõ. Đọc và sao lưu bằngzalo-mcp db query/zalo-mcp db backup, không mởzalo.dbbằngsqlite3.Presence on-demand là mặc định của server HTTP: socket Zalo đóng sau 5 phút rảnh và mở lại ở lần gọi tool hay chờ tin kế tiếp; tin đến trong lúc đó được bù khi kết nối lại. MCP qua stdio vẫn luôn kết nối. Cần thời gian thực (webhook ngay lập tức):
ZALO_PRESENCE_MODE=always-on.Tên theo biệt danh trước: mọi kết quả gọi một người bằng biệt danh bạn đặt cho họ, rồi tên Zalo (như các ứng dụng của Zalo).
senderNamegiờ ưu tiên biệt danh; giá trị gốc nằm ởsenderAliasvàsenderZaloName.Rời nhóm là xóa lịch sử cục bộ của nhóm (tự rời, bị mời ra, bị chặn, nhóm giải tán), như các ứng dụng của Zalo; sự kiện
group_gonebáo điều đó. Muốn giữ:groups.onLeave: "keep"trongstorage.json.Lệnh CLI phá hủy cần
--yes:account export,logout,account remove,db export --plaintext,msg undo,group leave, … không làm gì và thoát mã 2 nếu thiếu nó;--dry-runcho xem trước.
Related MCP server: wx4py-mcp
🚀 Bắt đầu nhanh
Bạn có thể chọn Cách 1 (Cài đặt toàn cục qua npm) hoặc Cách 2 (Cài đặt thư mục biệt lập 1 dòng lệnh). Cả hai cách đều đăng ký lệnh zalo-mcp vào PATH để bạn sử dụng ở mọi nơi.
Cách 1: Cài đặt toàn cục qua npm (Global CLI)
npm install -g @ardennguyen/zalo-mcpCách 2: Cài đặt thư mục cách ly (1 dòng lệnh)
Mọi phụ thuộc (dependencies) sẽ được tải vào một thư mục cách ly (zalo-mcp/), tạo file .env và tự động liên kết lệnh zalo-mcp toàn cục (npm link). Bạn có thể cài đặt ở bất kỳ đâu trên máy tính chỉ với 1 lệnh duy nhất:
macOS / Linux:
curl -fsSL https://raw.githubusercontent.com/ardennguyen/zalo-mcp/main/zalo-mcp.sh | bash -s installWindows (PowerShell):
Set-ExecutionPolicy Bypass -Scope Process -Force; irm https://raw.githubusercontent.com/ardennguyen/zalo-mcp/main/zalo-mcp.ps1 | Out-File $env:TEMP\zalo-mcp.ps1; & $env:TEMP\zalo-mcp.ps1 installTrình cài đặt 1-click sẽ làm gì?
Tạo thư mục
zalo-mcptại vị trí hiện tại.Tải các file wrapper và cấu hình.
Cài đặt các gói Node.js vào thư mục
node_modules/cục bộ.Liên kết lệnh
zalo-mcptoàn cục (npm link) để chạy từ mọi thư mục.Tạo file cấu hình
.envcho Port (ZALO_MCP_HTTP_PORT).
Phân tách file .env được khuyến nghị: Chỉ nên dùng zalo-mcp/.env để cấu hình PORT (ZALO_MCP_HTTP_PORT). Các biến môi trường điều hướng thư mục lưu trữ (ZALO_CREDENTIALS_DIR, ZALO_DATA_DIR, ZALO_MEDIA_DIR, ZALO_OA_DIR) và cấu hình engine nên đặt tại ~/.zalo-agent-cli/.env (<CONFIG_DIR>/.env) để cả zalo-mcp lẫn zalo-agent luôn đọc chung một nguồn cấu hình duy nhất.
Sử dụng lệnh zalo-mcp
Sau khi cài đặt (bằng Cách 1 hoặc Cách 2), bạn có thể chạy zalo-mcp trực tiếp từ bất kỳ đâu trong PowerShell, CMD, hoặc Bash mà không cần cd vào thư mục cài đặt hay dùng npm run:
# Khởi chạy MCP server (mặc định: stdio, hoặc thêm --http 3847)
zalo-mcp
zalo-mcp --account <ID>
zalo-mcp --http 3847 --account <ID> # HTTP trên 127.0.0.1; token lấy từ ZALO_MCP_AUTH_TOKEN (xem dưới)
# Chuyển tiếp mọi lệnh CLI của zalo-agent-cli (hỗ trợ --account <ID> cho từng lệnh)
zalo-mcp login
zalo-mcp account list
zalo-mcp --account <ID> msg list --json
zalo-mcp --account <ID> listen
zalo-mcp oa init --app-id <YOUR_APP_ID> --secret <YOUR_APP_SECRET>
zalo-mcp --helpToken của HTTP nằm trong file, không bao giờ trên dòng lệnh. --auth <token> hiện trong ps và lịch sử shell. Đặt ZALO_MCP_AUTH_TOKEN=<token> (hoặc ZALO_MCP_AUTH_TOKEN_<ID>= cho từng tài khoản) trong ~/.zalo-agent-cli/.env, chỉ user của bạn đọc được (chmod 600). Tạo token: openssl rand -hex 32. Đừng dùng --host 0.0.0.0: trong mạng LAN hãy bind địa chỉ LAN và mở firewall cho subnet đó; ra internet thì đặt sau một proxy TLS. Bộ cấu hình mẫu: máy bàn / LAN qua HTTP, VPS.
🔑 Đăng nhập & Xác thực
Mọi thông tin xác thực đều được lưu cục bộ và an toàn trên máy của bạn.
A. Zalo Cá Nhân (API Không chính thức)
Chạy lệnh đăng nhập:
zalo-mcp login(Hoặc
npm run loginnếu chạy trong thư mục cài đặt 1-click).Một mã QR sẽ hiển thị trên terminal. Mở app Zalo trên điện thoại > Quét mã QR (đừng dùng camera thường của điện thoại).
Sau đó đừng đăng nhập tài khoản này vào Zalo trên trình duyệt: nó sẽ đăng xuất phiên của
zalo-mcp. Điện thoại và ứng dụng Zalo trên máy tính vẫn dùng bình thường.
Vị trí lưu trữ Credentials: Mặc định tại ~/.zalo-agent-cli/ (quyền 0600, niêm phong bằng khóa của tài khoản từ 3.0). Có thể tách riêng credentials, database (zalo.db), và media sang các ổ đĩa khác nhau bằng cách khai báo ZALO_CREDENTIALS_DIR, ZALO_DATA_DIR, ZALO_MEDIA_DIR trong ~/.zalo-agent-cli/.env (<CONFIG_DIR>/.env).
Cảnh báo: Đây là API không chính thức, tài khoản cá nhân của bạn có thể bị khóa (ban) nếu dùng để spam liên tục. Không nên dùng nick chính.
B. Zalo Official Account (API v3.0 Chính thức)
Khởi tạo kết nối OA:
zalo-mcp oa init --app-id <YOUR_APP_ID> --secret <YOUR_APP_SECRET>(Hoặc
npm run oa:init -- --app-id <YOUR_APP_ID> --secret <YOUR_APP_SECRET>trong thư mục cài đặt).Làm theo hướng dẫn trên trình duyệt để ủy quyền ứng dụng.
Vị trí lưu trữ Credentials: Mặc định tại ~/.zalo-agent/oa-credentials.json, mỗi OA một bản ghi theo --oa-id (hoặc tùy chỉnh thư mục qua ZALO_OA_DIR trong ~/.zalo-agent-cli/.env). Lệnh zbs dùng chung đăng nhập OA đó; lệnh social lưu đăng nhập riêng ở social-credentials.json cùng thư mục, mỗi --profile một bản ghi. Webhook OA/ZBS: zalo-mcp oa listen --secret <OA_SECRET_KEY> (thêm --verify-file <file.html> hoặc --verify-meta '<meta …>' để xác thực domain, --app-id <id> khi chưa lưu App ID).
OA Access Tokens hết hạn sau 25 giờ. Refresh bất cứ lúc nào bằng lệnh: zalo-mcp oa refresh (hoặc npm run oa:refresh).
🤖 Tích hợp AI Agent (MCP)
Khi chạy zalo-mcp (hoặc node mcp-server.js) không có tên lệnh con (chỉ kèm các cờ như --account, --http, --auth, --host, --public-url, --cert/--key, --config, -w/--webhook, --webhook-secret, --no-self-heal, --no-delivered-receipts, --log-level), chương trình sẽ tự động khởi chạy zalo-agent mcp start (--auth vẫn dùng được nhưng làm lộ token trong ps; hãy dùng ZALO_MCP_AUTH_TOKEN). Dòng log khởi động che giá trị của --auth, --client-secret, --webhook-secret và --webhook. Xem chi tiết Ghim tài khoản (--account <ID>).
1. Claude Code (~/.claude/settings.json)
Sử dụng lệnh zalo-mcp toàn cục (1 tài khoản):
{
"mcpServers": {
"zalo": {
"command": "zalo-mcp",
"args": []
}
}
}Chạy nhiều tài khoản Zalo live cùng lúc (Multi-Account):
Mỗi tài khoản có database (zalo.db), thư mục media và daemon.lock tách biệt. Khai báo mỗi tài khoản là một MCP server kèm --account <ID> (lấy ID từ zalo-mcp account list) — cả hai tài khoản sẽ hoạt động song song mà không ghi đè accounts.json:
{
"mcpServers": {
"zalo-shop-a": {
"command": "zalo-mcp",
"args": ["--account", "101"]
},
"zalo-shop-b": {
"command": "zalo-mcp",
"args": ["--account", "202"]
}
}
}(Trên VPS: chạy engine trực tiếp dưới systemd, mỗi tài khoản một unit zalo-mcp@<ID> trên một port riêng của 127.0.0.1, token nằm trong file env của tài khoản đó (/etc/zalo-mcp/accounts/<ID>.env, quyền 600), Caddy phía trước cho TLS. zalo-agent fleet generate sinh ra unit, file env (kèm token) và Caddyfile; làm theo bộ cấu hình VPS và docs/deployment.vi.md. Khi gọi lệnh CLI song song, truyền zalo-mcp --account <ID> <lệnh> hoặc đặt biến ZALO_ACCOUNT=<ID>.)
Hoặc trỏ trực tiếp tới thư mục cài đặt 1-click:
{
"mcpServers": {
"zalo": {
"command": "node",
"args": ["/đường/dẫn/tuyệt/đối/zalo-mcp/mcp-server.js"],
"cwd": "/đường/dẫn/tuyệt/đối/zalo-mcp"
}
}
}2. Cursor
Thêm MCP server mới trong settings của Cursor:
Name:
zaloType:
stdioCommand:
zalo-mcp(hoặczalo-mcp --account <ID>, hoặcnode /đường/dẫn/tuyệt/đối/zalo-mcp/mcp-server.js)
🛠️ Quản lý & Cập nhật
Nếu cài đặt toàn cục qua npm:
Cập nhật:
npm install -g @ardennguyen/zalo-mcp@latestGỡ cài đặt:
npm uninstall -g @ardennguyen/zalo-mcp
Nếu dùng thư mục cài đặt 1-click:
Cập nhật bản mới nhất (Cập nhật engine, node_modules và làm mới liên kết
zalo-mcp):Windows:
.\zalo-mcp.ps1 updatemacOS / Linux:
./zalo-mcp.sh update
Dọn dẹp môi trường (Gỡ liên kết CLI và xóa sạch
node_modulesđể cài lại từ đầu):Windows:
.\zalo-mcp.ps1 cleanmacOS / Linux:
./zalo-mcp.sh clean
📖 Tài liệu đầy đủ
Wiki → github.com/ardennguyen/zalo-agent-cli/wiki
Hướng dẫn chi tiết cho tất cả lệnh, thiết lập MCP, cache cục bộ, Official Account API và nhiều hơn nữa — cả tiếng Việt lẫn tiếng Anh.
Giấy phép
zalo-mcp © 2026 Arden Nguyen Duc Huy được cấp phép theo CC BY-NC-SA 4.0. Xem LICENSE và NOTICE.
Miễn phí cho mục đích phi thương mại: cá nhân, học thuật, nghiên cứu. Không cấp phép cho mục đích thương mại — ví dụ dùng trong sản phẩm thương mại, để cung cấp dịch vụ có thu phí, hoặc trong hoạt động kinh doanh của một công ty. Muốn xin giấy phép thương mại, hãy mở một issue.
Ghi công: khi chia sẻ dự án này hoặc một phần của nó (nguyên bản hay đã sửa đổi, kể cả bên trong dự án khác), hãy ghi công theo mẫu trong NOTICE, nêu rõ bạn có sửa đổi hay không, và dẫn link giấy phép.
Chia sẻ tương tự (ShareAlike): bản sửa đổi được chia sẻ phải dùng CC BY-NC-SA 4.0 (hoặc phiên bản mới hơn, hoặc giấy phép tương thích do Creative Commons liệt kê).
Các phần dẫn xuất từ phần mềm MIT — bản phân phối
zalo-mcpgốc của PhucMPham — vẫn thuộc giấy phép MIT; xem NOTICE. Gói này cài@ardennguyen/zalo-agent-clitừ npm; engine đó cóLICENSEvàNOTICEriêng.Các phiên bản phát hành trước thay đổi này (1.0.16 trở về trước) được phát hành theo giấy phép MIT và giữ nguyên các điều khoản đó.
English
Self-contained Model Context Protocol (MCP) server and CLI wrapper for Zalo. Install globally via npm or use the 1-click sandboxed deployment script so AI agents (Claude Code, Cursor) can automate Zalo Personal & Official Accounts without cluttering your host system. Both installation methods provide the zalo-mcp command directly in your terminal.
What is the difference between zalo-mcp and zalo-agent-cli?
zalo-agent-cli: The core automation engine. It handles all API logic, authentication, CLI commands, and contains the actual MCP server source code.zalo-mcp(This Repo): The lightweight deployment and CLI wrapper. It contains no core engine code—it launches the MCP server and forwards all CLI subcommands to@ardennguyen/zalo-agent-cli. Whether you install it globally (npm i -g @ardennguyen/zalo-mcp) or use the 1-click script (which sets up a sandboxed folder with.envand runsnpm link), you can runzalo-mcpfrom any directory.
📋 Prerequisites
Node.js: v22.19 or higher (required for MCP server and CLI; engine 3.0 needs
>=22.19.0).Git: Required to pull dependencies.
@ardennguyen/zalo-agent-cli:zalo-mcp2.1.0 needs engine3.0.0or later (^3.0.0; the package installs a matching version). Engine 3.0.0 runs on its own Zalo protocol layer (no zca-js), and serves 37 MCP tools: every CLI command has an MCP action, the Official Account, ZBS and Social commands included throughzalo_official. A new engine tool or flag reacheszalo-mcponce you update (.\zalo-mcp.ps1 update/./zalo-mcp.sh update, ornpm install -g @ardennguyen/zalo-mcp@latestfor a global install). Wrappers 2.0.5–2.0.9 run engine 2.5.x. Version history: CHANGELOG.md.
Engine 3.0 changed the MCP contract. A client written for 2.x must switch:
One name per id: a message is
msgId(noidormessageId), a user isuserId(nouid), a message's author issenderId.zalo_view_mediatakesmsgId,zalo_delete_messagetakessenderId.threadTypeis"dm"or"group"in inputs and replies; a number is refused.Every id is a string, small ones too.
Destructive actions are asked about first.
zalo_undo,zalo_delete_message,zalo_groupleave, … needconfirm: true(dryRun: truepreviews).confirmModeinmcp-config.json(orZALO_MCP_CONFIRM_MODE) decides who confirms:agent(default; the first time it meets a guarded action, the agent is told to ask you how to handle them),human(the server asks you itself: by MCP elicitation under stdio, otherwise on a one-time approve page whose link is in the reply, which works over HTTP too) oroff.The new tools,
zalo_friend,zalo_groupandzalo_send_messagerefuse an input they do not take instead of ignoring it.
Engine 3.0 also changes how it runs:
One web login per account. The server is that login: a QR login into Zalo in a browser with the same account signs the server out. The phone and the Zalo desktop app are separate logins that coexist with it. Read and reply on the phone or in the desktop app beside the server; do not open the account in a browser.
Data is encrypted at rest: the saved login, the message database
zalo.dband media are sealed under each account's keys (DPAPI on Windows, the keychain on macOS, a passphrase on a VPS). The first 3.0 command converts existing data in place and keeps no plaintext copy. Read and back up withzalo-mcp db query/zalo-mcp db backup, notsqlite3.On-demand presence is the default for an HTTP server: the Zalo socket closes after 5 idle minutes and opens again on the next tool call or wait; what arrived meanwhile is caught up on reconnect. MCP over stdio stays connected. For real time (immediate webhooks):
ZALO_PRESENCE_MODE=always-on.Names are alias-first: every reply names a person by the alias you set for them, then their Zalo name (as Zalo's own apps do).
senderNameis now alias-first; the raw values are insenderAliasandsenderZaloName.Leaving a group deletes its local history (left, removed, blocked, or the group disbanded), as Zalo's own apps do; a
group_goneevent says so. To keep it:groups.onLeave: "keep"instorage.json.Destructive CLI commands need
--yes:account export,logout,account remove,db export --plaintext,msg undo,group leave, … do nothing and exit 2 without it;--dry-runpreviews.
🚀 Quick Start
Choose Option 1 (Global npm install) or Option 2 (One-Line Sandboxed Folder Install). Both methods register the zalo-mcp command on your PATH.
Option 1: Global npm Install (Global CLI)
npm install -g @ardennguyen/zalo-mcpOption 2: One-Line Sandboxed Installation
Downloads all dependencies into an isolated ./zalo-mcp folder, configures .env for ports (ZALO_MCP_HTTP_PORT), and links the zalo-mcp CLI command globally (npm link):
macOS / Linux:
curl -fsSL https://raw.githubusercontent.com/ardennguyen/zalo-mcp/main/zalo-mcp.sh | bash -s installWindows (PowerShell):
Set-ExecutionPolicy Bypass -Scope Process -Force; irm https://raw.githubusercontent.com/ardennguyen/zalo-mcp/main/zalo-mcp.ps1 | Out-File $env:TEMP\zalo-mcp.ps1; & $env:TEMP\zalo-mcp.ps1 installRecommended .env split: Keep zalo-mcp/.env for PORT settings only (ZALO_MCP_HTTP_PORT). Place storage directory overrides (ZALO_CREDENTIALS_DIR, ZALO_DATA_DIR, ZALO_MEDIA_DIR, ZALO_OA_DIR) and engine settings in ~/.zalo-agent-cli/.env (<CONFIG_DIR>/.env) so both zalo-mcp and zalo-agent share a single source of truth.
Using the zalo-mcp Command
Once installed (via Option 1 or Option 2), you can run zalo-mcp directly from anywhere in PowerShell, CMD, or Bash without cd-ing into an installation folder or using npm run:
# Start the MCP server (default: stdio, or pass --http 3847)
zalo-mcp
zalo-mcp --account <ID>
zalo-mcp --http 3847 --account <ID> # HTTP on 127.0.0.1; the token comes from ZALO_MCP_AUTH_TOKEN (below)
# Pass any zalo-agent-cli command and arguments right through (with optional --account <ID>)
zalo-mcp login
zalo-mcp account list
zalo-mcp --account <ID> msg list --json
zalo-mcp --account <ID> listen
zalo-mcp oa init --app-id <YOUR_APP_ID> --secret <YOUR_APP_SECRET>
zalo-mcp --helpThe HTTP token goes in a file, never on the command line. --auth <token> shows in ps and in your shell history. Put ZALO_MCP_AUTH_TOKEN=<token> (or ZALO_MCP_AUTH_TOKEN_<ID>= per account) in ~/.zalo-agent-cli/.env, readable by your user only (chmod 600). Make one with openssl rand -hex 32. Do not use --host 0.0.0.0: on a LAN bind the LAN address and open the firewall to that subnet; for the internet put a TLS proxy in front. Ready-made sets: desktop / LAN over HTTP, VPS.
🔑 Authentication
A. Personal Zalo Account (Unofficial API)
Run the login command:
zalo-mcp login(Or
npm run logininside a 1-click deployment directory).Scan the printed QR code using the Zalo app on your phone.
Then do not log this account into Zalo in a browser: that signs
zalo-mcpout. The phone and the Zalo desktop app keep working.
Credentials Storage: Defaults to ~/.zalo-agent-cli/ (0600 permissions, sealed under the account's keys since 3.0). To separate credentials, the SQLite database (zalo.db), and media onto different volumes, set ZALO_CREDENTIALS_DIR, ZALO_DATA_DIR, and ZALO_MEDIA_DIR in ~/.zalo-agent-cli/.env (<CONFIG_DIR>/.env).
Safety Notice: This uses an unofficial API. Your personal account can get banned if heavily abused for spam.
B. Zalo Official Account (Official API v3.0)
Initialize OA credentials:
zalo-mcp oa init --app-id <YOUR_APP_ID> --secret <YOUR_APP_SECRET>(Or
npm run oa:init -- --app-id <YOUR_APP_ID> --secret <YOUR_APP_SECRET>inside the deployment directory).Follow the browser prompt. Refresh tokens anytime with:
zalo-mcp oa refresh(ornpm run oa:refresh).
Credentials Storage: Defaults to ~/.zalo-agent/oa-credentials.json, one record per OA (--oa-id); move the folder with ZALO_OA_DIR in ~/.zalo-agent-cli/.env. The zbs commands use that OA login; the social commands keep their own login in social-credentials.json in the same folder, one record per --profile. OA/ZBS webhook: zalo-mcp oa listen --secret <OA_SECRET_KEY> (add --verify-file <file.html> or --verify-meta '<meta …>' for domain verification, and --app-id <id> when no App ID is saved).
🤖 AI Agent Integration (MCP)
When invoked with no subcommand (or only MCP server flags such as --account, --http, --auth, --host, --public-url, --cert/--key, --config, -w/--webhook, --webhook-secret, --no-self-heal, --no-delivered-receipts, --log-level), zalo-mcp starts the MCP server (zalo-agent mcp start; --auth still works but shows the token in ps: prefer ZALO_MCP_AUTH_TOKEN). The startup log line masks the values of --auth, --client-secret, --webhook-secret and --webhook. See Account Pinning (--account <ID>) for details.
Claude Code (~/.claude/settings.json):
Using the global zalo-mcp command (single account):
{
"mcpServers": {
"zalo": {
"command": "zalo-mcp",
"args": []
}
}
}Running multiple live Zalo accounts simultaneously (Multi-Account):
Each account has its own isolated SQLite cache (zalo.db), media folder, and daemon.lock. Declare one mcpServers entry per account with --account <ID> (from zalo-mcp account list) — both accounts run live in parallel without mutating accounts.json:
{
"mcpServers": {
"zalo-shop-a": {
"command": "zalo-mcp",
"args": ["--account", "101"]
},
"zalo-shop-b": {
"command": "zalo-mcp",
"args": ["--account", "202"]
}
}
}(On a VPS: run the engine itself under systemd, one zalo-mcp@<ID> unit per account on its own 127.0.0.1 port, its token in that account's env file (/etc/zalo-mcp/accounts/<ID>.env, mode 600), Caddy in front for TLS. zalo-agent fleet generate writes the units, the env files (tokens included) and the Caddyfile; follow the VPS set and docs/deployment.md. For concurrent CLI calls, pass zalo-mcp --account <ID> <command> or set ZALO_ACCOUNT=<ID>.)
Or pointing directly to the 1-click deployment directory:
{
"mcpServers": {
"zalo": {
"command": "node",
"args": ["/absolute/path/to/zalo-mcp/mcp-server.js"],
"cwd": "/absolute/path/to/zalo-mcp"
}
}
}Cursor: Add new MCP server (stdio) -> zalo-mcp (or zalo-mcp --account <ID>, or node /absolute/path/to/zalo-mcp/mcp-server.js).
🛠️ Management Commands
Global npm install:
Update:
npm install -g @ardennguyen/zalo-mcp@latestUninstall:
npm uninstall -g @ardennguyen/zalo-mcp
1-click deployment folder:
Update Deps & CLI Link:
.\zalo-mcp.ps1 updateor./zalo-mcp.sh updateClean Env & Unlink CLI:
.\zalo-mcp.ps1 cleanor./zalo-mcp.sh clean
📖 Documentation
Full Wiki → github.com/ardennguyen/zalo-agent-cli/wiki
Detailed guides for all commands, MCP setup, local cache, Official Account API, and more — available in both English and Tiếng Việt.
License
zalo-mcp © 2026 Arden Nguyen Duc Huy is licensed under CC BY-NC-SA 4.0. See LICENSE and NOTICE.
Free for non-commercial use (personal, academic, research). Commercial use is not licensed — for example in a commercial product, to provide paid services, or in a company's business operations. To request a commercial license, open an issue.
Credit required: if you share this project or any part of it, as-is or modified (including inside another project), credit it as shown in NOTICE, say whether you made changes, and link to the license.
ShareAlike: shared modifications must be released under CC BY-NC-SA 4.0 (or a later version, or a compatible license listed by Creative Commons).
Portions derived from MIT-licensed software — the original
zalo-mcpdistribution by PhucMPham — remain under the MIT License; see NOTICE. This package installs@ardennguyen/zalo-agent-clifrom npm; that engine carries its ownLICENSEandNOTICE.Versions published before this change (1.0.16 and earlier) were released under the MIT License and keep those terms.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Hosted Meta Ads MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Hosted Telegram MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
MCP server for AI agents: posts, messages and comments on WhatsApp, Instagram, TikTok and Facebook.
Hosted Amazon Seller Central and Amazon Ads MCP server for Claude, ChatGPT, Cursor, and agents.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceWhatsApp MCP server that exposes messaging, groups, contacts, and profile management as tools and resources for AI agents, supporting Baileys and Meta Cloud API.29MIT
- FlicenseNot gradedqualityDmaintenanceMCP server for WeChat PC automation, enabling message sending, voice/video calls, and AI-powered listening through Cursor or WorkBuddy.2-
- AlicenseNot gradedqualityBmaintenanceMCP server exposing WhatsApp Cloud API operations as tools for AI agents like Claude Code, Cursor, and Codex.MIT
- AlicenseNot gradedqualityBmaintenanceMCP server for self-hosted Telegram multi-account management, enabling encrypted session storage, health checks, batch operations, device-session management, and automation through AI agents.26MIT