Skip to content

PCB Design Rule Editing (DRC) ​

Inspect native PCB design rules, create named rule profiles, and update active board rules through a two-phase Prepare → Approve → Confirm → Readback workflow.

Version Requirement

Requires MCP server >= 1.1.0, extension >= 0.2.0, and an active PCB tab (documentType: 3) in EasyEDA Pro. See Upgrading & Compatibility.

Two-Phase Edit Workflow ​

mermaid
sequenceDiagram
    participant U as Human
    participant A as AI Client
    participant S as MCP Server
    participant E as EasyEDA Extension (eda.pcb_Drc)

    A->>S: 1. easyeda_get_drc_rules({ scope: "current" })
    S->>E: getDrcRules
    E-->>A: Raw rule JSON + target identity + capabilities
    A->>S: 2. easyeda_prepare_drc_edit({ operation })
    S->>E: prepareDrcEdit (no write)
    E-->>A: editId + preview (before, requestedAfter, changedKeys)
    A->>U: 3. Show preview & ask approval for editId
    U-->>A: Approve editId
    A->>S: 4. easyeda_confirmed_action({ action: "editDrcRules", params: { editId }, confirmation })
    S->>E: Verify target/rules unchanged -> write -> native readback
    E-->>A: status: "applied" (documentSaved: false)

Supported Operations ​

Pass one operation to easyeda_prepare_drc_edit:

operation.typePayload FieldsScope & Effect
createConfigurationconfigurationName: string, config: objectsaved_rule_configuration — Creates a new named rule profile with allowOverwrite: false (never overwrites existing/system profiles).
updateCurrentConfigurationconfig: objectactive_pcb — Replaces the active PCB's rule configuration ({ name, config }.config).
replaceNetRulesrules: object[]active_pcb — Replaces the entire per-net rule table ([] clears the table).
replaceNetByNetRulesrules: objectactive_pcb — Replaces the net-by-net rule object keyed by category ({} clears categories).
replaceRegionRulesrules: object[]active_pcb — Replaces the entire region rule table ([] clears the table).

Preserving Editor Units & Structure

easyeda_get_drc_rules with scope: "current" returns { name, config } using the editor's native structure and units (mm or mil). When calling createConfiguration or updateCurrentConfiguration, copy the inner config object, modify the desired fields, and pass config (not the { name, config } wrapper).

Example Payloads ​

json
{
  "operation": {
    "type": "createConfiguration",
    "configurationName": "JLCPCB-2Layer-0.15mm",
    "config": {
      "Safe Spacing": {},
      "Track": {},
      "Via Size": {}
    }
  }
}
json
{
  "action": "editDrcRules",
  "params": {
    "editId": "bd549553-e96d-4c9b-bb1f-f8e8ac28cf89"
  },
  "confirmation": "CONFIRM editDrcRules bd549553-e96d-4c9b-bb1f-f8e8ac28cf89"
}

Safety Guarantees & Error Recovery ​

  • Dual confirmation gate: Both the MCP server and the browser extension verify CONFIRM editDrcRules <editId> before touching eda.pcb_Drc.
  • Stale-state protection: Before writing, the extension re-verifies the PCB documentId, projectId, tabId, WebSocket session generation, and current rule state. Any change returns stale_edit without writing.
  • Expiration & single execution: Previews expire after 15 minutes (edit_expired) and can only be executed once (edit_already_started).
  • Full readback verification: An edit is marked applied only if eda.pcb_Drc returns true and a subsequent native readback matches the requested JSON.
  • Explicit PCB save: Applying DRC rules sets documentSaved: false. Saving the PCB requires a separate easyeda_confirmed_action (action: "save").

Handling Timeouts (drc_edit_outcome_unknown)

If the WebSocket times out or disconnects after a DRC write was dispatched, the server returns error: "drc_edit_outcome_unknown" with retryable: false. Never automatically replay the mutation. Call easyeda_get_drc_edit_result with the same editId to check whether the write completed.

Official EasyEDA Pro API References ​

Released under the MIT License. Not affiliated with, endorsed by, or sponsored by EasyEDA or JLCPCB (Shenzhen Jia Chuang Ban Technology Co., Ltd.). EasyEDA and EasyEDA Pro are trademarks of their respective owners.