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. For textures, this includes type, face count, slice count, and a cubemap flag. |
|
Gets a preview of a texture. Saves as a temporary PNG file. Accepts an optional |
|
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. Polls the two-phase capture protocol internally so a single call returns the image. Saves as a temporary PNG file. |
|
Gets current FPS, frame times, rendering statistics, GPU object counts, and staging buffer usage. |
|
Gets frames-per-second (FPS) information from the Kanzi Domain main loop. |
|
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. Writes one file per active writer — |
|
Fetches the most recent |
|
Fetches the most recent |
|
Captures a kzTrace snapshot (engine-native tracing, requires Debug or Profiling build). |
|
Fetches the most recent kzTrace as JSON. |
|
Lists registered trace writers with name, description, and current active state. |
|
Activates a trace writer by name (e.g. |
|
Deactivates a trace writer by name. Deactivating all writers stops trace output. |
|
Gets all data sources and DataObject trees. |
|
Sets a value in a DataObject tree. |
|
Gets Overwatch service status. |
|
Gets all active FontRuntimes with font identity, style, glyph cache state, metrics, and node info. |
|
Gets a preview of a font’s glyph cache texture. Saves as a temporary PNG file. |
|
Sets the glyph cache texture size for newly created caches. Requires |
|
Gets graphics backend and device information. |
|
Gets recent log entries. |
|
Sets the log buffer size at runtime. |
|
Gets the current log buffer configuration. |
|
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.Binary trace responses (
fetch_perfetto_trace):.perfetto-tracefiles are protobuf binaries and cannot traverse the text-mode command protocol as-is. The C++ side base64-encodes the bytes inside a JSON envelope; the MCP tool decodes the base64 and writes the resulting binary to a temporary.perfetto-tracefile, returning the path. The AI assistant can pass the path on to a trace analyser or open it in Perfetto UI.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¶
take_screenshotpolls the two-phase capture protocol internally, so a single call returns the image. If it reports Screenshot timed out — render stage did not complete, the application is not rendering new frames. When running in Studio Preview, ensure Allow preview to update if not in focus is enabled.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.