python
Run complex scripts to customize Inkscape documents. Use code to programmatically control elements, styles, and geometry directly on the live SVG canvas.
Instructions
Run Python (inkex) against the live document in one undoable step — anything the other tools
cannot express. In scope: svg (root element), by_id(id), selected (ids), inkex, etree, Transform,
frames (frames.content(el) maps an element's coordinates to page px), to_px('3mm'), qname('inkscape:label'),
unique_id(base), parse_style/style_str. print() output and result = … come back. readonly=True
skips the document reload (fast inspection). timeout_s: give up waiting after this long (the
result is then UNCERTAIN COMPLETION: the code may still finish and apply).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>"
},
"name": "python"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| readonly | No | ||
| timeout_s | No | ||
| expected_revision | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |