Skip to main content
Glama

Repair CAD Script

repair_script

Use this when evaluate_script reported an error and you want the fix applied rather than described. Takes the candidates why_did_this_fail derives for a diagnostic, applies them one at a time, re-evaluates after each, and keeps the first that clears the diagnostic without introducing new errors. Never edits outside the repair region (failing feature statement + its input statements + the param() lines it reads) — an out-of-region patch is refused with tool.repair.out-of-region. Returns the repaired source in new_code (the caller persists it), a unified diff, and before/after health maps. Pass { file? | code?, diagnostic?: ''|'first-error', strategy?: 'apply-first'|'try-all'|'dry-run', max_attempts?: number }.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeNoInline kernelCAD script source.
fileNoPath to a .kcad.ts script file. Hosted server: cannot read files from your machine — pass `code`, or `project:<slug>` for a saved project.
intentNoThe user's request in one sentence, in the user's own words and language (e.g. 'M4 bracket for a 25 mm tube, print on Bambu A1'). Helps kernelCAD improve; leave out personal data.
strategyNo'try-all' (default) walks candidates until one clears the diagnostic; 'apply-first' applies only the top candidate and reports what it did; 'dry-run' previews every candidate patch without evaluating.
diagnosticNoDiagnostic id from why_did_this_fail's `targetDiagnosticId` / `candidates[].diagnosticId`, or 'first-error' (default) for the first error-severity diagnostic.
max_attemptsNoUpper bound on candidates attempted (default 3). Ignored by apply-first and dry-run.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • removedOutput schema / properties
      Removed value: -{
      -  "after": {
      -    "additionalProperties": true,
      -    "description": "Post-repair { ok, featureHealth, diagnostics }.",
      -    "type": "object"
      -  },
      -  "applied": {
      -    "description": "Candidate id that was accepted.",
      -    "type": "string"
      -  },
      -  "attempts": {
      -    "description": "Per-candidate outcome { candidateId, applied, ok?, clearedDiagnostic?, newErrorCodes?, accepted, diagnostic? }.",
      -    "items": {
      -      "additionalProperties": true,
      -      "type": "object"
      -    },
      -    "type": "array"
      -  },
      -  "before": {
      -    "additionalProperties": true,
      -    "description": "Pre-repair { ok, featureHealth, diagnostics }.",
      -    "type": "object"
      -  },
      -  "candidateReason": {
      -    "type": "string"
      -  },
      -  "candidateStatus": {
      -    "enum": [
      -      "candidates",
      -      "no-automatic-candidate"
      -    ],
      -    "type": "string"
      -  },
      -  "candidates": {
      -    "items": {
      -      "additionalProperties": true,
      -      "type": "object"
      -    },
      -    "type": "array"
      -  },
      -  "diagnostics": {
      -    "description": "tool.repair.* diagnostics when repair could not complete.",
      -    "items": {
      -      "additionalProperties": true,
      -      "type": "object"
      -    },
      -    "type": "array"
      -  },
      -  "diff": {
      -    "description": "Unified diff of the accepted patch (dry run: every candidate patch).",
      -    "type": "string"
      -  },
      -  "error": {
      -    "type": "string"
      -  },
      -  "errorCode": {
      -    "type": "string"
      -  },
      -  "new_code": {
      -    "description": "Repaired .kcad.ts source (present when a patch applied). Caller persists it.",
      -    "type": "string"
      -  },
      -  "ok": {
      -    "description": "Whether a candidate cleared the target diagnostic without new errors.",
      -    "type": "boolean"
      -  },
      -  "repairRegion": {
      -    "additionalProperties": true,
      -    "description": "The line ranges the repair was bound to.",
      -    "type": "object"
      -  },
      -  "strategy": {
      -    "enum": [
      -      "apply-first",
      -      "try-all",
      -      "dry-run"
      -    ],
      -    "type": "string"
      -  },
      -  "target": {
      -    "additionalProperties": true,
      -    "description": "The diagnostic this run targeted { id, code, featureId?, message }.",
      -    "type": "object"
      -  }
      -}
    • removedOutput schema / required
      Removed value: -[
      -  "ok",
      -  "strategy",
      -  "candidates",
      -  "attempts"
      -]
  2. Changed1 schema field changed
    • addedInput schema / properties / intent
      Added value: +{
      +  "description": "The user's request in one sentence, in the user's own words and language (e.g. 'M4 bracket for a 25 mm tube, print on Bambu A1'). Helps kernelCAD improve; leave out personal data.",
      +  "maxLength": 2000,
      +  "type": "string"
      +}
  3. Changed1 schema field changed
    • changedInput schema / properties / file / description
      Previous value: -"Path to a .kcad.ts script file."New value: +"Path to a .kcad.ts script file. Hosted server: cannot read files from your machine — pass `code`, or `project:<slug>` for a saved project."
  4. Added

TDQS

Score is being calculated.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.