Building a Local Zabbix Assistant with MCP Server, Ollama and Streamlit
1. Introduction: Making Monitoring Easier with AI
Monitoring teams regularly need quick answers to questions such as:
- Which hosts currently have High or Disaster severity problems?
- Is any interface down?
- What is the current CPU or memory utilization of a particular server?
- Which servers are currently unavailable?
Although Zabbix provides dashboards, reports, and extensive monitoring capabilities, finding specific information often requires navigating multiple pages and applying filters.
The idea behind this work was simple: build a conversational assistant that allows Network Operations Center (NOC) members to ask monitoring-related questions in natural language and receive answers directly from Zabbix.
The important part is that the entire AI processing workflow runs locally. Instead of sending monitoring information to an external AI service, the application uses Ollama to run a local language model, MCP to communicate with monitoring tools, and Streamlit to provide the user interface.
The assistant is also designed to be read-only. It can retrieve monitoring information, but it cannot acknowledge problems, modify configurations, or perform administrative operations.

2. Architecture: How the Components Work Together
The application consists of four primary components, each responsible for a specific part of the workflow.
Flow Diagram:

Zabbix Server
Zabbix is the primary data source. The application communicates with it through its JSON-RPC API using an API token.
This allows the assistant to retrieve information about hosts, problems, interfaces, monitoring items, and environment statistics.
MCP Server
The MCP server acts as the communication layer between the Python application and Zabbix. It exposes a generic tool called zabbix_api, which accepts an API method and its parameters.
Ollama and the Local Language Model
Ollama runs the language model locally. The initial implementation uses qwen2.5:7b.
The model interprets the user's question, selects an appropriate tool, supplies its arguments, and converts the returned information into a readable response.
Streamlit Application
Streamlit provides the frontend, including the chat interface, navigation sidebar, tools page, Zabbix information page, logs, and settings.

3. What Is MCP, and Why Use It?
The Model Context Protocol (MCP) provides a standardized way for AI applications to discover and interact with external tools and data sources.
Instead of writing custom communication logic for every possible AI interaction, an application can expose functionality through MCP tools that an AI model can discover and call.
However, this flexibility also introduced an important challenge.
4. The First Attempt: Why One Generic Tool Wasn't Enough
The first version exposed the generic zabbix_api tool directly to the language model.
The model received a lengthy system prompt containing API instructions, method names, parameter requirements, and examples of common Zabbix queries.
On paper, this approach was flexible. In practice, it created unnecessary complexity.
A relatively small 7B model running on a CPU had to make several decisions simultaneously:
- Identify the correct Zabbix API method.
- Construct valid JSON parameters.
- Remember API field restrictions.
- Understand relationships between hosts, items, interfaces, and problems.
- Convert raw monitoring values into readable units.
A simple interface query required multiple API calls, parameter handling, and value conversions. This often confused the model, slowed responses, or resulted in empty replies.
The takeaway: smaller models perform better with fewer decisions to make.
5. The Redesign: Four Purpose-Built Tools
Rather than asking the model to construct complex API requests, the application was redesigned around four dedicated tools.
| Tool | Purpose |
|---|---|
| zabbix_overview | Retrieves version, host count, active problems, and High/Disaster counts. |
| host_info | Retrieves host details, groups, templates, and availability. |
| hardware_info | Retrieves CPU, memory, disk, temperature, uptime, and network information. |
| alert_info | Retrieves problems filtered by host, severity, time period, or acknowledgement. |
The model now has a much simpler responsibility: select the appropriate tool and provide a few straightforward arguments.
For example, a question about CPU utilization only requires selecting hardware_info and identifying the host.
Python Handles the Complex Operations
The actual API logic resides in Python handlers rather than the language model.
These handlers are responsible for:
- Resolving host names into Zabbix host IDs.
- Executing the appropriate API queries.
- Converting relative time periods such as 24h into Unix timestamps.
- Formatting raw values into readable measurements.
- Handling missing data and API errors.
- Limiting the number of returned results.
For instance, raw network values are converted into Mbps or Gbps, uptime is presented in days and hours, and interface operational status is translated into readable terms such as up or down.
The application also handles ambiguous host names. If multiple hosts match a search, it returns the matching candidates instead of allowing the model to guess.
Tool Schemas Guide the Model
Each tool has a JSON schema describing its name, purpose, accepted arguments, and parameter types.
These descriptions help Ollama understand what each tool does and when it should be selected.
This separation is important: the model makes the decision, while Python performs the precise operations.
6. A Shorter System Prompt, Better Results
Another important improvement was reducing the system prompt.
The original instructions contained several thousand characters explaining API methods and query construction. After introducing dedicated tools, the prompt was reduced to approximately 1,000 characters.
It now focuses on a few essential rules:
- The assistant is strictly read-only.
- Answers must be based on tool results.
- Ambiguous host names require clarification.
- Errors and missing data must be reported honestly.
- Responses should be concise.
- Retrieved values should be presented as provided by the Python handlers.
The tool descriptions now provide most of the operational guidance.
This reduced unnecessary instructions and allowed the model to focus on understanding questions rather than remembering API documentation.
7. Multi-Turn Conversations and Chat History
A monitoring assistant becomes much more useful when users can ask follow-up questions without repeating the entire context.
For example:
User: How many hosts currently have High severity problems?
Assistant: Three hosts currently have High severity problems.
User: What about their CPU utilization?
The application passes a limited portion of previous conversation history to Ollama, allowing the model to understand references such as "their CPU utilization" or "that host."
To avoid unnecessarily increasing inference time, the application limits conversation history using both a message count and a character budget.
The current implementation retains up to six previous messages, with a history budget of approximately 3,000 characters.
Users can also export their conversations as text files.

8. The Interface: A Practical Monitoring Workspace
The frontend was designed using Streamlit, with a dark theme, subtle red accents, and a layout that resembles a modern monitoring application.
Branding and Navigation
The company logo appears in the top-left corner of the application header, while the Zabbix logo serves as the primary page heading.
The sidebar provides navigation to five sections:
- Chat
- Tools
- Zabbix Info
- Logs
- Settings
It also displays the connection status of the MCP server and Zabbix, allowing users to identify connectivity problems quickly.
Tools Page
The Tools page groups predefined operations into four categories: Overview, Host, Hardware, and Alerts.
Users can execute common monitoring queries with a single click. Operations requiring additional information, such as a host name or network port, provide input fields.

Zabbix Info Page
This page retrieves information directly through the MCP connection without involving the language model.
It displays the Zabbix version, host count, active problems, High/Disaster counts, and recent problems.
By bypassing the LLM, these queries avoid unnecessary inference time.

Logs Page
The Logs page provides visibility into the assistant's tool-calling behaviour.
It records the selected tool, its arguments, and a shortened preview of the returned result. This is particularly useful when investigating incorrect tool selections or unexpected responses.

Settings Page
The Settings page allows users to configure the assistant's local model and conversation behaviour.
It includes options for managing chat history, adjusting the context window, and displaying technical details during processing. It also provides live visibility into MCP server and Zabbix connection status.

9. Security: What Does Read-Only Actually Mean?
Security is enforced through read-only Python handlers and a restricted Zabbix API account. While the system prompt instructs the assistant not to modify data, actual access control must be enforced through a dedicated Zabbix user with a read-only role and API token. Sensitive credentials and configuration should be stored in environment variables or Streamlit secrets, never hardcoded.
10. Current Limitations
The application is a practical starting point, but there are limitations worth understanding.
Template dependency: Hardware queries currently rely on standard Zabbix item-name patterns. Custom templates may require modifications to the matching logic.
Limited results: Queries return capped result sets, generally between 10 and 25 records, depending on the operation.
No historical analysis: The current tools focus on current monitoring values and recent problems. Long-term performance trends, historical peaks, and averages are not yet implemented.
Model accuracy: Smaller models can still select an inappropriate tool or misunderstand a question. The Logs page helps identify these issues.
These limitations are part of the current implementation, not problems that should be hidden from users.
11. Conclusion
Building a local Zabbix assistant demonstrated that integrating AI into monitoring does not necessarily require cloud services or complicated infrastructure. MCP provides a standardized tool interface, Ollama handles local language processing, and Streamlit delivers a practical conversational experience. The most important lesson was that a smaller model does not need to understand every detail of the Zabbix API. It simply needs to choose the right tool and provide the correct arguments. By keeping the actual API operations, validation, and data formatting in Python, the application becomes more predictable, easier to troubleshoot, and better suited to running locally. The goal is not to make the model do everything, but to give it a few well-defined responsibilities and let code handle the rest.
More Blogs
Discover the latest insights and trends in technology with the Qavi Tech Blog. Stay updated with expert articles, industry news, and innovative ideas.
Planning an Elastic Deployment? Get the Official Checklist (Free PDF)
Reduce risks, improve performance, accelerate go-live.

