run_script
Execute Python scripts with full access to klayout.db for advanced layout editing and creation. Captures stdout output and supports session rebinding.
Instructions
Execute Python with klayout.db available (advanced).
Injected names: db (klayout.db), klayout, session (current
LayoutSession or None), LayoutSession. stdout is captured and returned.
A script may rebind session to a new LayoutSession to make it the active
layout. Runs locally in-process with full Python access.
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": "run_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |