zapi-mcp
English | 日本語
MCP (Model Context Protocol) server for the Zabbix API.
Built for network operations: a single daily_brief call summarizes active
problems plus site-specific categories (DHCP pool usage, SNAT session usage,
core-network problems, …), and individual tools query problems, hosts, and item
values. Organization-specific tags live in a config file, not the code, so the
server stays generic.
Version-adaptive auth: works against Zabbix 6.0 LTS (user + auth field) and
forward-compatible with 6.4 / 7.0 (username + Authorization: Bearer).
Documentation: https://shigechika.github.io/zapi-mcp/
Features
| Tool | Description |
|---|---|
health_check |
Server version, Zabbix connectivity/auth, detected API version, and configured daily_brief categories — call at session start or after a timeout |
daily_brief |
Morning patrol: active problems (Warning+) plus one section per configured category |
get_problems |
Active problems by severity and tag, newest-first with age; header shows the true total (showing N of TOTAL when capped); output includes eventid |
get_hosts |
List hosts filtered by role/tag/group, with IP and tags |
get_host_items |
Current item values for a host (server-side host filter) |
acknowledge_problem |
Acknowledge problems and add a message (does not close them) |
set_maintenance |
Open an idempotent Zabbix maintenance window, selecting hosts by location tag or by exact host name (exactly one of the two) |
Setup
# uv
uv pip install zapi-mcp
# pip
pip install zapi-mcp
Or from source:
git clone https://github.com/shigechika/zapi-mcp.git
cd zapi-mcp
# uv
uv sync
# pip
pip install -e .
Configuration
Set the following environment variables:
| Variable | Description | Default |
|---|---|---|
ZABBIX_URL |
Zabbix base URL (e.g. https://zabbix.example.com); /api_jsonrpc.php is appended if absent |
required |
ZABBIX_USER |
Zabbix API user | required |
ZABBIX_PASSWORD |
Zabbix API password | required |
ZABBIX_CATEGORIES_INI |
Path to a categories INI file for daily_brief (optional) |
— |
ZABBIX_BRIEF_RECENT_HOURS |
daily_brief "recent" window in hours; problems older than this are folded to a count |
24 |
ZABBIX_BRIEF_PROBLEM_LIMIT |
Max active problems daily_brief fetches per call before counting the rest |
1000 |
The API user needs read permission for the host groups you query, plus
acknowledge permission if you use acknowledge_problem, and maintenance-write
permission if you use set_maintenance.
Active problems in daily_brief
Problems are grouped by severity and listed newest-first, each annotated with
its age (e.g. 3h ago). Problems older than the recent window
(ZABBIX_BRIEF_RECENT_HOURS, default 24h) are folded to a single
… and N older (stale; oldest …) line — so a backlog of alerts that Zabbix
keeps active because their recovery is never auto-confirmed (ICMP ping down, RDP
down, …) doesn't bury what just happened. Section headers carry the true total
and show showing N of TOTAL when the fetch is capped, never a silent truncation.
Categories for daily_brief (optional)
daily_brief always lists active problems. To add site-specific sections —
DHCP pool exhaustion, SNAT session usage, core-network problems — point
ZABBIX_CATEGORIES_INI at an INI file. Each [section] is one category:
[dhcp]
name = DHCP Pool Usage
# Zabbix host tag identifying the group
tag = dhcp-pool-usage
# report current values for this exact item key
item_key = usage
# flag values >= this
threshold = 80
[snat]
name = SNAT Session Pool
tag = snat-pool-usage
# substring match (catches pool.node0.usage etc.)
item_key_search = .usage
threshold = 80
[core]
name = Core Network
tag = role
# the tag must equal this value
tag_value = main
# no item key -> report active problems instead
tag(required): host tag identifying the category. Withtag_value, the tag must equal it (Equal); without, any host carrying the tag matches (Exists).item_key/item_key_search: when either is set, the section reports current item values sorted high-to-low.item_keymatches the key exactly; useitem_key_searchfor keys that embed an id (e.g..usagecatchespool.node0.usage). When neither is set, it reports active problems for the tag.threshold: optional; values at or above it are flagged.
See categories.ini.example. When the variable is
unset or the file is missing, daily_brief reports active problems only.
Usage
Claude Code
Add to .mcp.json:
{
"mcpServers": {
"zapi-mcp": {
"type": "stdio",
"command": "zapi-mcp",
"env": {
"ZABBIX_URL": "https://zabbix.example.com",
"ZABBIX_USER": "api-user",
"ZABBIX_PASSWORD": "",
"ZABBIX_CATEGORIES_INI": "/path/to/categories.ini"
}
}
}
}
Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"zapi-mcp": {
"command": "zapi-mcp",
"env": {
"ZABBIX_URL": "https://zabbix.example.com",
"ZABBIX_USER": "api-user",
"ZABBIX_PASSWORD": ""
}
}
}
}
Direct Execution
export ZABBIX_URL=https://zabbix.example.com
export ZABBIX_USER=api-user
export ZABBIX_PASSWORD=your-password
zapi-mcp
CLI Options
zapi-mcp --version # Print version and exit
zapi-mcp --check # Verify environment variables and authentication, then exit
zapi-mcp --brief # Print the daily_brief to stdout and exit (handy for cron)
zapi-mcp # Start MCP server (STDIO, default)
--check exit codes: 0 success, 1 config error, 2 auth/connection error.
--brief exit codes: 0 success, 1 a section failed (auth, the active-problems
fetch, or category loading — see the embedded Error: line in the output).
Development
git clone https://github.com/shigechika/zapi-mcp.git
cd zapi-mcp
# uv
uv sync --dev
uv run pytest -v
uv run ruff check .
# pip
python3 -m venv .venv
.venv/bin/pip install -e . && .venv/bin/pip install pytest pytest-cov respx ruff
.venv/bin/pytest -v
.venv/bin/ruff check .
Live smoke test
pytest checks logic against fixtures; it cannot tell you that a tool has
stopped returning real data. scripts/smoke_test.py runs every registered
tool against the configured Zabbix and fails on empty, malformed or error
answers:
# needs the same ZABBIX_* environment variables as the server
uv run python scripts/smoke_test.py
uv run python scripts/smoke_test.py --only get_problems --traceback
- Read-only.
acknowledge_problemandset_maintenanceare skipped by name — an acknowledgement is visible to every operator and cannot be quietly undone, andset_maintenanceopens a real maintenance window that suppresses alerts — and a test enforces that. The report prints tool names and statuses only, never payloads; server-authored error text is redacted too, since Zabbix quotes the host it was asked about.--tracebackstill shows the full text on the operator's own terminal. - Arguments that would identify real hosts, groups or tag values are
discovered at run time, never written into
scripts/smoke_probes.py. Two tests enforce that: one refuses those parameters as literals, the other bans anything address-shaped (mail address, URL, hostname, IPv4, IPv6) anywhere in the file. - An empty answer is a real observation here — a monitoring system with nothing wrong is the goal — so probes assert the envelope the tool must produce rather than a row count.
- CI enforces the cheap half: a tool registered without a probe spec fails the
build (
tests/test_smoke_probes.py), so adding a tool forces the question "how would we know it works?". scripts/smoke_harness.pyis the engine and holds no Zabbix knowledge: it is kept identical across the servers that share it, so fix engine bugs once and sync the file rather than patching this copy.
Releasing
Releases are automated with release-please.
Merging Conventional Commits (feat:, fix:, …)
to main keeps a release PR open with the next version and changelog. Merging
that PR tags vX.Y.Z and publishes a GitHub Release, whose release: published
event triggers the release workflow to build and publish to PyPI and the MCP
Registry. release-please owns the version in zapi_mcp/__init__.py and
server.json (do not bump them by hand).
[!IMPORTANT] The release-please workflow should be given a repository secret
RELEASE_PLEASE_TOKEN(a PAT withcontents: write+pull-requests: write). The defaultGITHUB_TOKENcannot create the Release that triggers the downstreamreleaseworkflow (GitHub blocks workflow runs triggered byGITHUB_TOKEN), so without the PAT nothing gets published. The workflow falls back toGITHUB_TOKENwhen the secret is unset so PR CI keeps working on forks.
Roadmap
- Streamable HTTP transport + OAuth2 for remote / mobile use
- Visual rendering of key metrics
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zapi_mcp-0.8.0.tar.gz.
File metadata
- Download URL: zapi_mcp-0.8.0.tar.gz
- Upload date:
- Size: 35.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24acd9d4739d08a3176cf05e4b57a04b562eda4b5db54279b5fd5f1dc65586d8
|
|
| MD5 |
b0e1cbca20b8b2b7bb3cfb376c0730d0
|
|
| BLAKE2b-256 |
0e40d802c496bf9de885a1b1e59d9421227d04106066aa26e9187e703dcad08e
|
Provenance
The following attestation bundles were made for zapi_mcp-0.8.0.tar.gz:
Publisher:
release.yml on shigechika/zapi-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zapi_mcp-0.8.0.tar.gz -
Subject digest:
24acd9d4739d08a3176cf05e4b57a04b562eda4b5db54279b5fd5f1dc65586d8 - Sigstore transparency entry: 2405879633
- Sigstore integration time:
-
Permalink:
shigechika/zapi-mcp@7ad8e1408aee8d563135bf4af5ab4f29df3662f0 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/shigechika
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ad8e1408aee8d563135bf4af5ab4f29df3662f0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file zapi_mcp-0.8.0-py3-none-any.whl.
File metadata
- Download URL: zapi_mcp-0.8.0-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
571a6410a4a7549da29f9be93864c34a8e7f3369b57002a69d2f99a4e7a341a7
|
|
| MD5 |
08738711732e8fab4c85c215889f9c3b
|
|
| BLAKE2b-256 |
4e04124e30f5e357d1c54c09d4e3999063bc311db23dd00495154d96f853587a
|
Provenance
The following attestation bundles were made for zapi_mcp-0.8.0-py3-none-any.whl:
Publisher:
release.yml on shigechika/zapi-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zapi_mcp-0.8.0-py3-none-any.whl -
Subject digest:
571a6410a4a7549da29f9be93864c34a8e7f3369b57002a69d2f99a4e7a341a7 - Sigstore transparency entry: 2405879649
- Sigstore integration time:
-
Permalink:
shigechika/zapi-mcp@7ad8e1408aee8d563135bf4af5ab4f29df3662f0 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/shigechika
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ad8e1408aee8d563135bf4af5ab4f29df3662f0 -
Trigger Event:
release
-
Statement type: