mcp-z-api — Claude Code MCP server: WhatsApp via Z-API
An MCP server that lets your agent send WhatsApp messages through a Z-API instance: text, media, contacts and groups.
claude mcp add mcp-z-api -e ZAPI_TOKEN=<ZAPI_TOKEN> -- npx -y @codespar/mcp-z-apiWhat mcp-z-api does
The package sits between the agent and Z-API and exposes 27 tools. An agent can fire off text, an image, a document or audio, pull the contact list, test whether a number is on WhatsApp, and read a contact's avatar and metadata. Another set covers chats and groups: paged chat listing, marking things read, creating a group, adding or removing members, fetching group metadata.
Interactive payloads are there too — a button list, the native option list, and CALL, URL or REPLY action buttons. Labels let you tag a chat and enumerate the tags. Z-API authenticates with an instance ID and a token that travel inside the request URL.
Sign up at the Z-API developer portal and copy your instance ID and token first; without them the server has nothing to talk to. The platform configs shown below only carry ZAPI_TOKEN, so check Z-API's docs for how the second value is passed. MIT licensed, shipped as the npm package @codespar/mcp-z-api.
What it helps with
- send a WhatsApp message or file from inside an agent session
- verify a number is on WhatsApp before you message it
- page through chat and group lists
- spin up a group and add members to it
- mark messages read or delete them
Example prompts for the agent
- Send a WhatsApp text to the number listed in
contacts.json - Check whether that number has WhatsApp and fetch its profile picture
- Create a group called Project and add two participants
How to install mcp-z-api
Platform CLI
claude mcp add mcp-z-api -e ZAPI_TOKEN=<ZAPI_TOKEN> -- npx -y @codespar/mcp-z-apiReplace <…> with your own values
Platform CLI
codex mcp add z-api --env ZAPI_TOKEN=<ZAPI_TOKEN> -- npx -y @codespar/mcp-z-apiReplace <…> with your own values
Config file
{
"mcpServers": {
"z-api": {
"command": "npx",
"args": [
"-y",
"@codespar/mcp-z-api"
],
"env": {
"ZAPI_TOKEN": "<ZAPI_TOKEN>"
}
}
}
}Replace <…> with your own values
Config file
{
"servers": {
"z-api": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@codespar/mcp-z-api"
],
"env": {
"ZAPI_TOKEN": "<ZAPI_TOKEN>"
}
}
}
}Replace <…> with your own values
Platform CLI
gemini mcp add -e ZAPI_TOKEN=<ZAPI_TOKEN> z-api npx -y @codespar/mcp-z-apiReplace <…> with your own values
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about mcp-z-api
How do I install mcp-z-api in Claude Code?
Run claude mcp add mcp-z-api -e ZAPI_TOKEN=<ZAPI_TOKEN> -- npx -y @codespar/mcp-z-api. Alternatively use claude mcp add --env ZAPI_TOKEN=<ZAPI_TOKEN> --transport stdio z-api -- npx -y @codespar/mcp-z-api.
What does mcp-z-api do?
It wires Z-API's WhatsApp tools into your agent: sending messages and media, contacts, chats, labels, groups, plus interactive lists and buttons.
What do I need before it works?
A Z-API instance — an account at the developer portal plus its instance ID and token. Tools have no WhatsApp connection without a live instance.