Submit

Zabbix Mcp

@mpeirone

πŸ”Œ Complete MCP server for Zabbix integration - Connect AI assistants to Zabbix monitoring with 40+ tools for hosts, items, triggers, templates, problems, and more. Features read-only mode and comprehensive API coverage.
Overview

Installation

Prerequisites

  • Python 3.10 or higher
  • uv package manager
  • Access to a Zabbix server with API enabled

Quick Start

  1. Clone the repository:

    git clone https://github.com/mpeirone/zabbix-mcp-server.git
    cd zabbix-mcp-server
    
  2. Install dependencies:

    uv sync
    
  3. Configure environment variables:

    cp config/.env.example .env
    # Edit .env with your Zabbix server details
    
  4. Test the installation:

    uv run python scripts/test_server.py
    

Configuration

Required Environment Variables

  • ZABBIX_URL - Your Zabbix server API endpoint (e.g., https://zabbix.example.com)

Authentication (choose one method)

Method 1: API Token (Recommended)

  • ZABBIX_TOKEN - Your Zabbix API token

Method 2: Username/Password

  • ZABBIX_USER - Your Zabbix username
  • ZABBIX_PASSWORD - Your Zabbix password

Optional Configuration

  • READ_ONLY - Set to true, 1, or yes to enable read-only mode (only GET operations allowed)

Usage

Running the Server

With startup script (recommended):

uv run python scripts/start_server.py

Direct execution:

uv run python src/zabbix_mcp_server.py

Testing

Run test suite:

uv run python scripts/test_server.py

Read-Only Mode

When READ_ONLY=true, the server will only expose GET operations (retrieve data) and block all create, update, and delete operations. This is useful for:

  • πŸ“Š Monitoring dashboards
  • πŸ” Read-only integrations
  • πŸ”’ Security-conscious environments
  • πŸ›‘οΈ Preventing accidental modifications

Example Tool Calls

Get all hosts:

host_get()

Get hosts in specific group:

host_get(groupids=["1"])

Create a new host:

host_create(
    host="server-01",
    groups=[{"groupid": "1"}],
    interfaces=[{
        "type": 1,
        "main": 1,
        "useip": 1,
        "ip": "192.168.1.100",
        "dns": "",
        "port": "10050"
    }]
)

Get recent problems:

problem_get(recent=True, limit=10)

Get history data:

history_get(
    itemids=["12345"],
    time_from=1640995200,
    limit=100
)

MCP Integration

This server is designed to work with MCP-compatible clients like Claude Desktop. See MCP_SETUP.md for detailed integration instructions.

Docker Support

Using Docker Compose

  1. Configure environment:

    cp config/.env.example .env
    # Edit .env with your settings
    
  2. Run with Docker Compose:

    docker compose up -d
    

Building Docker Image

docker build -t zabbix-mcp-server .

Development

Project Structure

zabbix-mcp-server/
β”œβ”€β”€ src/
β”‚   └── zabbix_mcp_server.py    # Main server implementation
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ start_server.py         # Startup script with validation
β”‚   └── test_server.py          # Test script
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ .env.example           # Environment configuration template
β”‚   └── mcp.json               # MCP client configuration example
β”œβ”€β”€ pyproject.toml             # Python project configuration
β”œβ”€β”€ requirements.txt           # Dependencies
β”œβ”€β”€ Dockerfile                 # Docker configuration
β”œβ”€β”€ docker-compose.yml         # Docker Compose setup
β”œβ”€β”€ README.md                  # This file
β”œβ”€β”€ MCP_SETUP.md              # MCP integration guide
β”œβ”€β”€ CONTRIBUTING.md           # Contribution guidelines
β”œβ”€β”€ CHANGELOG.md              # Version history
└── LICENSE                   # MIT license

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Running Tests

# Test server functionality
uv run python scripts/test_server.py

# Test with Docker
docker-compose exec zabbix-mcp python scripts/test_server.py

Error Handling

The server includes comprehensive error handling:

  • βœ… Authentication errors are clearly reported
  • πŸ”’ Read-only mode violations are blocked with descriptive messages
  • βœ”οΈ Invalid parameters are validated
  • 🌐 Network and API errors are properly formatted
  • πŸ“ Detailed logging for troubleshooting

Security Considerations

  • πŸ”‘ Use API tokens instead of username/password when possible
  • πŸ”’ Enable read-only mode for monitoring-only use cases
  • πŸ›‘οΈ Secure your environment variables
  • πŸ” Use HTTPS for Zabbix server connections
  • πŸ”„ Regularly rotate API tokens
  • πŸ“ Store configuration files securely

Server Config

{
  "mcpServers": {
    "zabbix": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/path/to/zabbix-mcp-server",
        "python",
        "src/zabbix_mcp_server.py"
      ],
      "env": {
        "ZABBIX_URL": "https://zabbix.example.com",
        "ZABBIX_TOKEN": "<your_api_token>",
        "READ_ONLY": "true"
      }
    }
  }
}
Β© 2025 MCP.so. All rights reserved.

Build with ShipAny.