MCP tools
ztk --mcp app.tcl runs the script on the headless backend and then serves the Model Context Protocol on stdin and stdout: one JSON-RPC message on each line. The output of the script goes to stderr. The app runs only inside the calls of the tools, so two runs with the same calls give the same answers. The trace is on from the start.
| Tool | Arguments | What it gives |
|---|---|---|
ui_tree |
path |
The answer of ztk::debug tree. |
ui_explain |
path, option |
The answer of ztk::debug explain. |
ui_geometry |
path |
The geometry chain, one line for each level. |
ui_click |
path, button |
The answer of ztk::debug click. |
ui_type |
text, path |
The answer of ztk::debug type. |
ui_ran |
seq |
The answer of ztk::debug ran. |
ui_trace |
kind, widget, last |
The trace records, one line each (default: the last 20). |
ui_mark |
name |
Takes a mark for ui_diff. |
ui_diff |
name, image |
The answer of ztk::debug changes. With image, also the PNG with the changed pixels in red. |
ui_snapshot |
path |
A PNG image of the widget. |
tcl_eval |
script |
The result of the script at the global level, after an update. |
An MCP client that starts a server from a command line gets the command ztk and the arguments --mcp /path/to/app.tcl.
An example
Visual diffs has a session with ui_mark, tcl_eval, and ui_diff: the JSON-RPC lines, and the answer that names the moved widget. tests/debug-examples.sh runs it.