Using the Kanzi Monitor MCP server¶
The Kanzi Monitor MCP server is a Python tool that exposes Kanzi Monitor console commands — the Overwatch, Capture, Debug, NodeTree and Resource services — 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 Kanzi Monitor console commands, such as overwatch.*, nodetree.*, resource.*, debug.* and capture.*, 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 Kanzi Monitor console commands as structured tools, covering the Overwatch, Capture, Debug, NodeTree and Resource services.
Tool |
Description |
|---|---|
|
Gets the node tree as JSON. Accepts an optional depth limit. |
|
Gets a node’s locally-set property values, each with its |
|
Sets a property value on a node. |
|
Dispatches a message from a node. Takes the arguments as a dictionary of argument name to value, each value formatted as for |
|
Lists the resources that have a URL, with memory usage. The count and memory totals cover every resource, so they can exceed the entries listed. See Which resource list to use. |
|
Lists every resource the |
|
Gets detailed metadata for a resource, by handle (preferred), URL or 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. |
|
Sets the |
|
Forces a resource into existence by URL, reporting whether it still exists afterwards. |
|
Drops the URL association so the next acquire rebuilds the resource. Not a delete; the way to pick up an edited |
|
Creates a resource of any concrete class, sets its properties and registers it under a URL, or none, and returns its handle. Resource service, see Using the Resource service. |
|
Drops a created resource and its URL, and reports whether that destroyed it. |
|
Drops every resource created in this session. |
|
Lists the created resources Monitor keeps alive, with their handles and references. |
|
Lists the builders with their arguments, and which resource classes can be created. |
|
Adds a face of another weight or style to any font family. |
|
Appends a fallback family to any font family, the application’s own included, for the glyphs its fonts lack: CJK, emoji. |
|
Creates a node of a metaclass under a parent node, and returns its handle and path; an application override of the metaclass applies. NodeTree service, see Using the NodeTree service. |
|
Instantiates a prefab 1 to 10000 times under a parent node, and reports every copy’s handle and path. |
|
Takes any node out of the tree, by path or handle, and reports whether it was destroyed. |
|
Takes any node out of the tree without destroying it, and returns its handle, by which |
|
Puts a detached node back under its parent at the index it was taken from. |
|
Puts every detached node back, the most recently detached first, which restores the original order. |
|
Puts a detached node, or one created without a parent, anywhere in the tree. |
|
Moves any node to another parent, or to another position among its siblings, in one step. |
|
Lists the nodes the NodeTree service tracks, attached or detached: handle, state, origin, current path and, for a detached node, its home. |
|
Destroys every node created in this session, and removes every node component Monitor added, from created and application nodes alike. |
|
Adds a node component of any class to a node, its properties (a dictionary of name to value) written before it attaches. See Adding node components. |
|
Lists a node’s components, with whether Monitor added each, whether it is attached, and a trigger’s action and condition counts. |
|
Removes a named component from a node, whoever added it. |
|
Sets a property of a node’s named component. An Animation Player applies most of its properties at the next Play or Resume. |
|
Reports Kanzi’s base resource directory, which decides what a relative resource path means. |
|
Sets that directory. Mainly for Android, where resources otherwise come from inside the APK. |
|
Lists FBO-backed render targets. |
|
Gets the render pass tree. |
|
Gets a preview of a render pass output. Saves as a temporary PNG file. |
|
Gets a render pass’s locally-set property values, each with its |
|
Sets one property on a render pass. Same value formats as |
|
Gets any resource’s locally-set property values, addressed by handle or URL, and names the resource the key reached. |
|
Sets one property on any resource, addressed by handle or URL. Same value formats as |
|
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. |
|
Arms the in-RAM frame ring and records continuously until |
|
Freezes the ring so the frames it holds can be fetched. |
|
Gets the capture state, frames held and capacity, per-frame readback cost, peak bytes, and rendered frames against captured. |
|
Gets per-frame metadata: index, frame number, source frame, timestamp, inter-frame delta and dimensions. Use |
|
Fetches one captured frame by index. Saves as a temporary PNG file. |
|
Fetches every frame the ring currently holds — not every frame recorded, because the ring overwrites the oldest. Saves the frames as temporary PNG files and assembles them into a video, MP4 by default or APNG, with playback timed from the captured timestamps. |
|
Lists every property breakpoint, each with its condition, actions, hit counters, and whether it is armed. An entry reporting |
|
Adds a property breakpoint that breaks, logs, captures a screenshot, or runs a console command when a node property meets a condition. Takes the node path, property name, comparison and value, with an optional hit count and a once-only flag. The condition is evaluated inside the assignment that changed the property, so with a debugger attached the |
|
Removes one breakpoint by the ID |
|
Activates or deactivates one breakpoint without removing it. Activating resets the hit count, so a breakpoint with a hit target starts counting from zero again. |
|
Sets the Monitor console command a breakpoint runs when it triggers, and enables that breakpoint’s command action. The command runs with no console attached, so its output goes to the application log, readable with |
|
Removes every property breakpoint. |
|
Fetches the screenshot a breakpoint’s screenshot action captured. Reports |
|
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. |
|
Lists every property breakpoint, each with its condition, actions, hit counters, and whether it is armed. An entry reporting |
|
Adds a property breakpoint that breaks, logs, captures a screenshot, or runs a console command when a node property meets a condition. Takes the node path, property name, comparison and value, with an optional hit count and a once-only flag. The hit count must not be negative: no change count reaches a negative target, so such a value is rejected rather than dropped, which would have armed a breakpoint that triggers on every change instead. The condition is evaluated inside the assignment that changed the property, so with a debugger attached the |
|
Removes one breakpoint by the ID |
|
Activates or deactivates one breakpoint without removing it. Activating resets the hit count, so a breakpoint with a hit target starts counting from zero again. |
|
Sets the Monitor console command a breakpoint runs when it triggers, and enables that breakpoint’s command action. The command runs with no console attached, so its output goes to the application log, readable with |
|
Removes every property breakpoint. |
|
Fetches the screenshot a breakpoint’s screenshot action captured. Reports |
|
Captures a Monitor profiling trace to file. Writes one file per active writer — |
|
Empties the Monitor profiling trace storage, so the next |
|
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 the kzTrace categories the application registers, with their descriptions. Read-only, and separate from the profiling categories. See Listing the kzTrace categories. |
|
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. |
|
Lists the profiling categories (not kzTrace categories) and whether each is enabled, or gets one by name. A disabled category records nothing. See Choosing which profiling categories are recorded. |
|
Enables or disables one profiling category. |
|
Applies a category filter with the syntax of |
|
Returns every profiling category to its code default, then applies the startup filter again. A defined state, not an undo. |
|
Lists the kzb files the application loaded, optionally with their entries and byte sizes. |
|
Lists the registered property types, including project-authored ones. Supports filtering and paging. |
|
Lists the registered message types, including project-authored ones. Supports filtering and paging. |
|
Looks up one message type by exact name in the engine’s global registry. Answers what the listing cannot: whether a name that does not appear in it is unregistered, or merely unreachable from the sources the listing draws on. The name must match exactly; use |
|
Resolves the property and message types one class declares, across its base chain and its mixed-in concepts, each entry attributed to the class that declares it. Takes an exact class name. Not everything that influences a node: see What a class declares, in one call. |
|
Lists the registered metaclasses. Supports filtering and paging. |
|
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 the state of the GPU timestamp dump: whether it is on, its frame interval, and the graphics backend. It does not check the values. See the GPU timestamp dump. |
|
Enables or disables the per-frame and per-render-pass GPU timestamp dump. The lines arrive in the log, so read them with |
|
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. A framebuffer capture is oriented from therowOrderthe plugin reports with it, so it comes out upright on any backend; a texture or render-pass preview, which carries no such report, is flipped as GPU readback data conventionally requires. 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.