Set Parameter
set_paramUse this when you need to edit a param() default value in a kernelCAD script. Returns the modified code as text plus diagnostics from re-evaluating the result. Caller persists the new code via standard file-write tools (this tool has no side effects). With preview: true it builds the edit in a scratch session instead and returns the diff_geometry summary plus the requirements-ledger and S1 binding diffs (which requirements flip, which margins shrink, which selectors moved or re-bound), without touching the active session, source, revision or caches. A preview whose revised build fails returns ok:false and no diff. Inspect after.requirementsOk to see whether the edit preserves declared intent; preview.ok only says the preview could be computed. FEATURE MODE: pass { feature, changes } instead of param_name/new_value to change a feature's own literal arguments in place, by feature id (inspect({ of: 'features' }) lists ids and parameter names), e.g. { feature: 'cylinder_1', changes: { r: 3.3 } }. The argument is found from the feature's call site and each rewrite is verified by re-capturing the script; the whole model is rebuilt before and after, and the result carries new_code, edits (argument source before/after, line), changedParams (every feature parameter that moved) and the same geometry / requirementsDiff / bindings diff as preview. Writes nothing. A value driven by param() is refused with a hint to use set_param on that param instead.
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": "set_param"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The .kcad.ts source code. | |
| changes | No | Feature mode: the feature's parameters to set, by parameter name, in mm or deg (e.g. { r: 3.3 }). | |
| feature | No | Feature mode: id of the feature to edit in place (e.g. 'cylinder_1'). Use with `changes` instead of param_name/new_value. | |
| preview | No | S6 edit preview: evaluate the edit in a scratch session and return geometry + requirements-ledger + S1 binding diffs. Writes nothing. Default false (the normal source-edit result). | |
| new_value | No | The new default value. A number for a numeric param (e.g. 12.5), a string expression evaluated in the script (e.g. "width/2 + 3") or a choice/colour, or true/false for a boolean param. | |
| param_name | No | The string literal name of the param (first arg to param()). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||