mcpField
M
Mcp Zabbix

Mcp Zabbix

Local
github.com/badossCloud & Infra2Updated 24w ago

About Mcp Zabbix

MCP Zabbix is a Python server for connecting MCP-compatible AI assistants to the Zabbix monitoring API. It exposes monitoring and host-management tools, and can render trend graphs as PNG files and inline base64 data.

Key features

  1. 01List hosts, groups, items, and users
  2. 02Inspect current and host-specific problems
  3. 03Create Zabbix hosts
  4. 04Retrieve item trends
  5. 05Render graphs as PNG and base64
  6. 06Send email through optional SMTP

Use cases

  1. 01Reviewing monitored hosts and group membership
  2. 02Investigating active problems on a host
  3. 03Charting an item's metrics over a time range
  4. 04Emailing an alert through configured SMTP

MCP support

The server communicates with clients over MCP stdio and exposes Zabbix, graph-rendering, and optional email tools. It connects to Zabbix through its JSON-RPC API.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

MCP Zabbix

Python License: MIT MCP Code style: ruff Type-checked: mypy

A production-grade Model Context Protocol server that bridges the Zabbix monitoring API with AI assistants such as Claude Desktop, Cursor, and any other MCP-compatible client. Built on FastMCP with an async httpx client, typed Pydantic models, structured logging, and a trend-graph renderer that returns both an on-disk PNG and a base64 payload for inline display.


Table of contents


Architecture

                       ┌─────────────────────────────────────┐
                       │       AI Assistant / MCP Client     │
                       │   (Claude Desktop, Cursor, etc.)    │
                       └────────────────┬────────────────────┘
                                        │
                                        │   MCP stdio (JSON-RPC)
                                        ▼
        ┌──────────────────────────────────────────────────────────┐
        │                   FastMCP server (main.py)               │
        │  ┌────────────────────────────────────────────────────┐  │
        │  │  @mcp.tool registrations  →  async handlers        │  │
        │  └────────────────────────────────────────────────────┘  │
        │            │                  │                 │        │
        │            ▼                  ▼                 ▼        │
        │  ┌──────────────────┐  ┌────────────┐  ┌──────────────┐  │
        │  │  ZabbixClient    │  │  Email     │  │  Graph       │  │
        │  │  (httpx async,   │  │  (smtplib  │  │  (matplotlib │  │
        │  │   retry, auth)   │  │   thread)  │  │   PNG+b64)   │  │
        │  └────────┬─────────┘  └─────┬──────┘  └──────┬───────┘  │
        │           │                  │                │          │
        │  ┌────────┴──────────────────┴────────────────┴──────┐   │
        │  │  core/  : Settings  •  Logger  •  Exceptions      │   │
        │  └───────────────────────────────────────────────────┘   │
        └────────────┬────────────────────────┬────────────────────┘
                     │                        │
                     ▼                        ▼
            ┌────────────────┐        ┌──────────────────┐
            │ Zabbix API     │        │  SMTP (Gmail)    │
            │ (JSON-RPC)     │        │                  │
            └────────────────┘        └──────────────────┘

A request from the AI assistant arrives over MCP stdio, is routed to an async tool handler, which delegates to the service layer (ZabbixClient, email, graph). Every layer pulls its configuration from a single pydantic-settings Settings object and logs through one rotating handler.


Highlights

  • Fully async — httpx.AsyncClient with bearer-token auth, configurable timeout, and exponential-backoff retries for transient failures.
  • Typed boundaries — Pydantic v2 models validate tool inputs (emails, IP addresses, time ranges) before they reach the network.
  • Single source of truth for config — pydantic-settings reads from process env then .env; secrets are wrapped in SecretStr.
  • Stdio-safe logging — rotating file handler + stderr stream (never pollutes the MCP protocol on stdout).
  • Graph rendering — saves a PNG to disk and returns base64 so MCP clients can render inline without a second round-trip.
  • Graceful degradation — the email tool is automatically disabled when SMTP credentials are missing, returning a structured error rather than crashing the server.
  • Tested — async pytest suite with respx-mocked HTTP, no real Zabbix required for CI.

Available tools

ToolSignatureDescription
get_zabbix_host()List hosts with interfaces, groups, and tags.
get_zabbix_host_group()List host groups.
get_zabbix_host_by_group(group_id: str)Hosts within a group.
get_zabbix_item(host_id: str)Items configured on a host.
get_zabbix_problem()Current problems (most recent first).
get_zabbix_problem_by_host(host_id: str)Problems for a single host.
get_zabbix_trend(item_id, start_time, end_time)Trend rows for an item.
get_zabbix_user()Users with roles and access flags.
get_zabbix_proxy()Proxy inventory.
get_zabbix_ha_cluster_nodes()HA cluster node state.
create_zabbix_host(hostname, ip, group_ids, ...)Create a host (agent/snmp/ipmi/jmx).
send_email_tool(to_email, subject, body)Send via SMTP.
construct_graph(item_id, start_time, end_time, item_name)Render trend chart (PNG + base64).

All Zabbix tools return the raw result payload from the JSON-RPC response. On failure they return a structured {"error": ..., "type": ...} envelope rather than throwing.


Project layout

mcp_zabbix/
├── src/mcp_zabbix/
│   ├── __init__.py
│   ├── main.py              # FastMCP entrypoint + tool registrations
│   ├── core/
│   │   ├── config.py        # pydantic-settings (env + .env)
│   │   ├── logging.py       # rotating file + stderr handlers
│   │   └── exceptions.py    # ZabbixAPIError / EmailError / GraphError
│   ├── models/
│   │   └── zabbix.py        # Pydantic schemas for tool I/O
│   └── services/
│       ├── zabbix.py        # async ZabbixClient (retry, auth)
│       ├── email.py         # SMTP wrapper (asyncio.to_thread)
│       └── graph.py         # matplotlib renderer (PNG + base64)
├── tests/
│   ├── conftest.py          # autouse env stubbing
│   ├── test_config.py
│   ├── test_zabbix_client.py  # respx-mocked HTTP
│   └── test_graph.py
├── Dockerfile               # python:3.12-slim, non-root user
├── docker-compose.yml       # mounts ./logs and ./output
├── pyproject.toml           # hatchling build, dev extras, ruff/mypy
├── requirements.txt         # mirror of runtime deps for pip users
├── run.sh                   # convenience launcher (loads .env)
├── .env.example
└── LICENSE

Quick start

Prerequisites
  • Python 3.10 or newer
  • A reachable Zabbix server with a valid API token
  • (Optional) Gmail / SMTP credentials for the email tool
Local (pip)
git clone https://github.com/badoss/mcp_zabbix.git
cd mcp_zabbix

python -m venv .venv
source .venv/bin/activate            # Windows: .venv\Scripts\activate

pip install -e ".[dev]"
cp .env.example .env                 # edit ZABBIX_API_URL / TOKEN
./run.sh                             # or: mcp-zabbix
Local (uv)

uv is a fast Rust-based replacement for pip:

uv sync                              # installs runtime deps
uv sync --extra dev                  # add dev tooling
cp .env.example .env
uv run mcp-zabbix
Docker
cp .env.example .env                 # edit secrets
docker compose up --build

./logs and ./output are mounted into the container so log files and generated PNGs persist on the host.


Configuration

All settings come from environment variables. A .env file in the project root is loaded automatically. Full list (see .env.example):

Zabbix
VariableDefaultDescription
ZABBIX_API_URL— (required)Full URL to api_jsonrpc.php.
ZABBIX_API_TOKEN— (required)Bearer token (stored as SecretStr).
ZABBIX_REQUEST_TIMEOUT30HTTP timeout in seconds.
ZABBIX_MAX_RETRIES3Transient-failure retry budget.
SMTP (optional)
VariableDefaultDescription
SMTP_HOSTsmtp.gmail.comSMTP server host.
SMTP_PORT587SMTP server port (STARTTLS).
SMTP_USERemptyLogin user; required to enable email.
SMTP_PASSWORDemptyLogin password or Gmail app password.
SMTP_FROM_NAMEMCP ZabbixDisplay name in the From header.

Gmail note: enable 2FA and create an app password — regular account passwords are no longer accepted by Google's SMTP.

Runtime
VariableDefaultDescription
LOG_LEVELINFODEBUG / INFO / WARNING / ERROR / CRITICAL.
LOG_DIRlogsRotating log directory (5 MB × 3 backups).
GRAPH_OUTPUT_DIRoutputWhere trend PNGs are written.

MCP client setup

Claude Desktop / Cursor (uv launcher)

~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "mcp-zabbix": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/absolute/path/to/mcp_zabbix",
        "mcp-zabbix"
      ]
    }
  }
}
pip-installed virtualenv
{
  "mcpServers": {
    "mcp-zabbix": {
      "command": "/absolute/path/to/mcp_zabbix/.venv/bin/mcp-zabbix"
    }
  }
}
Docker
{
  "mcpServers": {
    "mcp-zabbix": {
      "command": "docker",
      "args": ["compose", "-f", "/absolute/path/to/docker-compose.yml", "run", "--rm", "mcp-zabbix"]
    }
  }
}

Restart your MCP client after editing the config — the tools should then show up in its tool palette.


Usage examples

Once connected, prompt your assistant in plain language; it will pick the right tool automatically.

List monitored hosts

Show me every Zabbix host along with its group memberships.

Investigate problems on a host

What active problems does host 10084 have? Group them by severity.

Render a trend chart

Plot the last 24 hours of CPU utilization for item 50134 and call the chart "Web-01 CPU".

The construct_graph tool returns the on-disk path plus a base64-encoded PNG — most MCP clients will render the chart inline.

Send an alert email

Email [email protected] with subject "P1: DB latency" and a one-line body describing the current problem.

The email tool returns {"status": "sent", ...} on success, or a structured error envelope if SMTP isn't configured.


Development

pip install -e ".[dev]"

# run the test suite (async + respx-mocked HTTP)
pytest

# lint & format
ruff check src tests
ruff format src tests

# strict type-check
mypy src

The test suite uses pytest-asyncio (auto mode) and respx to mock httpx. No real Zabbix server is required for CI.

To run the server against your local Zabbix:

cp .env.example .env
$EDITOR .env
./run.sh

License

Released under the MIT License.

Support

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.