Using the Kanzi Monitor MCP server¶
The Kanzi Monitor MCP server is a Python tool that exposes Kanzi Monitor Overwatch commands as structured tools for AI assistants such as Claude Code and Claude Desktop. It connects to the Kanzi Monitor console over TCP or serial and enables AI agents to inspect and control a running Kanzi application through the Model Context Protocol.
You can find the tool in tools/monitor-mcp-server/. See tools/monitor-mcp-server/README.md for the full reference.
How the Kanzi Monitor MCP server works¶
Claude Code/Desktop ──(stdio)──> MCP Server (Python) ──(TCP or Serial)──> Monitor Console ──> Kanzi App
The MCP server runs as a subprocess of the AI assistant.
It receives tool calls over standard I/O using the Model Context Protocol and forwards them as overwatch.* commands to the Kanzi Monitor console.
The MCP server returns JSON responses from Kanzi Monitor to the AI assistant as structured tool results.
Large responses such as images and big JSON payloads are saved to temporary files to reduce context window consumption.
Requirements¶
Python 3.10 or later
mcppackage:pip install "mcp>=1.0.0"For serial connections:
pyserial-asyncio-fast:pip install pyserial-asyncio-fastA running Kanzi application with Kanzi Monitor and
ServiceOverwatchEnabled=1
Setting up the Kanzi Monitor MCP server¶
Setting up with Claude Code¶
The examples below assume that Kanzi Monitor is installed to the default location in your Kanzi workspace: Engine/plugins/monitor/.
Create a .mcp.json file in the root of your Kanzi application project:
{
"mcpServers": {
"kanzi-monitor": {
"command": "python",
"args": ["../../Engine/plugins/monitor/tools/monitor-mcp-server/kanzi_monitor_mcp.py"],
"env": {
"KANZI_MONITOR_HOST": "127.0.0.1",
"KANZI_MONITOR_PORT": "56000"
}
}
}
}
Setting up with Claude Desktop¶
To set up the Kanzi Monitor MCP server with Claude Desktop:
Open the Claude Desktop MCP settings file (
claude_desktop_config.json).Add the following entry:
{ "mcpServers": { "kanzi-monitor": { "command": "python", "args": ["C:/KanziWorkspace/Engine/plugins/monitor/tools/monitor-mcp-server/kanzi_monitor_mcp.py"], "env": { "KANZI_MONITOR_HOST": "127.0.0.1", "KANZI_MONITOR_PORT": "56000" } } } }
Replace
C:/KanziWorkspacewith the actual path to your Kanzi workspace.
Configuring the connection¶
All configuration uses environment variables in the MCP server configuration.
Variable |
Default |
Description |
|---|---|---|
|
|
Monitor TCP host. |
|
|
Monitor TCP port. |
|
|
Command timeout in seconds. |
|
(empty) |
Serial device path, for example |
|
|
Serial baud rate. Used only with |
To connect over serial instead of TCP, set KANZI_MONITOR_SERIAL_PORT in the environment:
{
"mcpServers": {
"kanzi-monitor": {
"command": "python",
"args": ["../../Engine/plugins/monitor/tools/monitor-mcp-server/kanzi_monitor_mcp.py"],
"env": {
"KANZI_MONITOR_SERIAL_PORT": "COM3",
"KANZI_MONITOR_BAUD_RATE": "115200"
}
}
}
}
Available tools¶
The MCP server exposes all Overwatch commands as structured tools.
Tool |
Description |
|---|---|
|
Gets the node tree as JSON. Accepts an optional depth limit. |
|
Gets all properties of a node. |
|
Sets a property value on a node. |
|
Lists loaded resources with memory usage. |
|
Lists all resources, including unloaded ones. |
|
Gets detailed metadata for a resource by index. |
|
Gets a preview of a texture. Saves as a temporary PNG file. |
|
Purges unused resources. |
|
Lists FBO-backed render targets. |
|
Gets the render pass tree. |
|
Gets a preview of a render pass output. Saves as a temporary PNG file. |
|
Captures a screenshot of the application. Saves as a temporary PNG file. |
|
Gets current FPS, frame times, rendering statistics, GPU object counts, and staging buffer usage. |
|
Gets application-level performance information. |
|
Gets the PerformanceInfo logging level. |
|
Sets the PerformanceInfo logging level. |
|
Lists active performance watchers. |
|
Adds a metric watcher that triggers a command when a threshold is crossed. |
|
Removes a watcher by ID. |
|
Resets a triggered watcher to active. |
|
Removes all watchers. |
|
Captures a Monitor profiling trace to file. |
|
Fetches the most recent Monitor profiling trace as JSON. |
|
Captures a kzTrace snapshot (engine-native tracing, requires Debug or Profiling build). |
|
Fetches the most recent kzTrace as JSON. |
|
Gets all data sources and DataObject trees. |
|
Sets a value in a DataObject tree. |
|
Gets Overwatch service status. |
|
Gets graphics backend and device information. |
|
Gets recent log entries. |
|
Gets KanziLog trace pipeline diagnostics. |
|
Gets the Monitor UI overlay visibility status for each node tree. |
|
Shows or hides the on-screen UI overlay. Accepts an optional |
|
Lists available BasicUI overlay screens and the current selection. |
|
Switches to a BasicUI overlay screen by index. |
|
Gets the current BasicUI overlay font scale. |
|
Sets the BasicUI overlay font scale. |
|
Gets the current MainLoopScheduler SuspendWhenIdle state. |
|
Enables or disables MainLoopScheduler SuspendWhenIdle. |
|
Sends a raw Kanzi Monitor command. |
|
Quits the Kanzi application. |
Response size optimization¶
The MCP server automatically reduces large responses to avoid consuming the AI assistant’s context window:
Image responses (
take_screenshot,get_texture_preview,get_render_pass_preview): Raw RGBA pixel data is converted to a temporary PNG file. All images are automatically flipped vertically to match screen orientation (GPU readback data is bottom-up). The tool returns the image dimensions, file path, and any non-pixel metadata. The AI assistant can then read the PNG file when it needs to see the image.Large text responses (
get_scene_tree,get_resources,get_all_resources,fetch_trace,get_data_sources): When a response exceeds 50 KB, it is written to a temporary JSON file. The tool returns the file path and a preview of the first 200 lines.
Temporary files are written to the system temp directory and are not automatically deleted.
Troubleshooting¶
MCP server does not connect¶
Verify that the Kanzi application runs with the Kanzi Monitor plugin loaded.
Check that
ServiceOverwatchEnabled=1is set inkanzimonitor.cfg.Confirm that the host and port match your
kanzimonitor.cfgsettings. TheRemoteConsolePortsetting defaults to56000.
Tools return timeout errors¶
Some commands, such as
take_screenshot, require two calls. The first call schedules the capture and the second retrieves the data.Increase
KANZI_MONITOR_TIMEOUTfor slow devices or serial connections.
Serial connection fails¶
Install
pyserial-asyncio-fast:pip install pyserial-asyncio-fast.Verify the serial port name, for example
COM3on Windows or/dev/ttyUSB0on Linux.Ensure that
SerialConsoleEnabled=1is set inkanzimonitor.cfg.
Property changes have no effect¶
Ensure that
OverwatchPropertyChangeEnabled=1is set inkanzimonitor.cfg.