easyeda-pro-mcp
by rawnullbyte
README.md
# easyeda-pro-mcp
[](https://github.com/rawnullbyte/easyeda-pro-mcp/actions/workflows/ci.yml)
[](./LICENSE)
A **Model Context Protocol** server plus an **EasyEDA Pro extension** that gives
AI agents (OpenCode, Claude, Cursor, VS Code, Codex, …) full read/write control
over a live EasyEDA Pro session — schematics, PCBs, copper layers, pours, DRC
rules, libraries, selection, navigation and manufacturing exports.
The agent can inspect the real editor, change it, and read the result back.
```
┌──────────────┐ stdio (MCP) ┌──────────────────┐ WebSocket ┌──────────────────┐
│ AI client │ ◄─────────────► │ easyeda-pro-mcp │ ◄────────────► │ EasyEDA Pro │
│ OpenCode/… │ │ bridge + tools │ 127.0.0.1 │ MCP Bridge .eext │
└──────────────┘ └──────────────────┘ 49620-49629 └──────────────────┘
```
- **No cloud, no credentials, no screenshots.** Everything runs locally.
- The extension dials out to the MCP server on loopback; the server never accepts
remote connections by default.
- **Exhaustive coverage:** a generated catalog of all **846 methods across 114
`eda.*` namespaces** (plus 103 enums) is callable through `easyeda_call_api`,
and a test walks the entire catalog to prove it. Typed tools (119) are
conveniences on top of that guarantee.
---
## Requirements
| Component | Version |
| --- | --- |
| EasyEDA Pro | 3.x or 4.x with Extension API support |
| Node.js | ≥ 20.11 (developed on 26.x) |
| OS | Windows, macOS, Linux |
EasyEDA Pro 2.x predates the `sys_WebSocket` API the bridge relies on; use 3.x or
newer.
The extension must be granted **Allow interactive with external** in EasyEDA's
Extension Manager. Without it, the bridge cannot open a WebSocket.
---
## Install
### 1. Get the extension
**Fastest:** download `easyeda-mcp-bridge_v1.0.0.eext` from
[Releases](https://github.com/rawnullbyte/easyeda-pro-mcp/releases).
**From source:**
```bash
git clone https://github.com/rawnullbyte/easyeda-pro-mcp.git
cd easyeda-pro-mcp
npm ci
npm run build
npm run package:extension
# dist/easyeda-mcp-bridge_v1.0.0.eext
```
When installed from npm, extract the bundled `.eext` instead:
```bash
npx -y easyeda-pro-mcp extension --out .
```
### 2. Install it in EasyEDA Pro
1. Open EasyEDA Pro.
2. **Extensions → Extension Manager → Install from file** (wording varies by
version) and pick `dist/easyeda-mcp-bridge_v1.0.0.eext`.
3. Open the extension's **Config** tab and tick **Allow interactive with external**
(optionally also **Show at header menu** so **MCP Bridge** appears in the top bar;
leave **Auto update** off for a locally built extension).
4. A **MCP Bridge** menu appears in the home, schematic, PCB, footprint and panel
editors. Use **Status…** to confirm it is waiting for the server.
The extension retries forever with exponential backoff, so you can start it
before or after the MCP server.
### 3. Register the MCP server
From a checkout, use `node /absolute/path/to/EasyEDA-Pro-MCP/dist/src/index.js`.
Once the package is published, `npx -y easyeda-pro-mcp` works the same way.
**OpenCode** (V2 — note `mcp.servers`, not `mcp.<name>`):
```sh
opencode mcp add easyeda-pro --global -- node /absolute/path/to/EasyEDA-Pro-MCP/dist/src/index.js
opencode mcp list
```
Or by hand in `opencode.jsonc`:
```json
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"servers": {
"easyeda-pro": {
"type": "local",
"command": ["npx", "-y", "easyeda-pro-mcp"]
}
}
}
}
```
Config reloads automatically; no restart needed. Use `/mcps` to check the
connection, and `disabled: true` (not `enabled`) to keep it configured but off.
**Claude Desktop** (`claude_desktop_config.json`):
```json
{
"mcpServers": {
"easyeda-pro": {
"command": "npx",
"args": ["-y", "easyeda-pro-mcp"]
}
}
}
```
**Cursor** (`.cursor/mcp.json`):
```json
{
"mcpServers": {
"easyeda-pro": {
"command": "npx",
"args": ["-y", "easyeda-pro-mcp"]
}
}
}
```
**VS Code** (`.vscode/mcp.json`):
```json
{
"servers": {
"easyeda-pro": {
"type": "stdio",
"command": "npx",
"args": ["-y", "easyeda-pro-mcp"]
}
}
}
```
**Codex** (`~/.codex/config.toml`):
```toml
[mcp_servers.easyeda-pro]
command = "npx"
args = ["-y", "easyeda-pro-mcp"]
```
Local-checkout variants are in [`examples/`](./examples).
### 4. Verify
```bash
node dist/src/index.js doctor
```
You should see the bridge port, the connected window and a successful execution
test. Inside the agent, call `easyeda_status`.
---
## Quick start
Ask the agent:
> Connect to EasyEDA and show me the current project and active document.
The agent calls `easyeda_status` → `easyeda_get_context` → `easyeda_list_documents`.
Then:
> Add a GND copper pour on the top layer covering the board, 0.2 mm clearance,
> thermal relief with 0.3 mm spokes.
The agent calls `easyeda_pcb_create_pour` with `clearanceMm: 0.2` and
`thermalRelief`, then `easyeda_pcb_rebuild_pours`.
---
## Tool reference
### Connection & discovery
| Tool | Purpose |
| --- | --- |
| `easyeda_status` | Transport, windows, active window, current context |
| `easyeda_list_windows` | All registered editor windows |
| `easyeda_select_window` | Route calls to one window |
| `easyeda_run_script` | **Escape hatch:** arbitrary async JS with `eda` in scope |
| `easyeda_execute` | Alias of `easyeda_run_script` |
| `easyeda_search_api` | Search the official API reference |
| `easyeda_get_api_doc` | Full markdown for a class/enum/interface |
| `easyeda_undo` / `easyeda_redo` | Undo/redo the last PCB command group |
### Exhaustive API access (every official method)
| Tool | Purpose |
| --- | --- |
| `easyeda_api_catalog` | Totals + namespace list for the generated catalog |
| `easyeda_list_api_methods` | Every method of a namespace, with parsed params and read/write classification |
| `easyeda_describe_method` | Exact signature, params, return type, call example |
| `easyeda_get_enum` | Enum members and values (`EPCB_LayerId.TOP` → `1`) |
| `easyeda_list_primitives_of_kind` | `getAll()` on any primitive store, snapshotted |
| **`easyeda_call_api`** | **Invoke any `eda.<namespace>.<method>(…)`** with enum/layer markers |
| **`easyeda_call_primitive_method`** | **Invoke any instance method** on one primitive |
`easyeda_call_api` accepts positional arguments in documented order, resolves
`{ "$enum": "EPCB_LayerId.TOP" }` to `1` and `{ "$layer": "top" }` to the live
layer id (including nested markers), and requires `confirm: true` for methods the
catalog classifies as mutating. In read-only mode, read methods still work and
mutating ones return `READ_ONLY`.
### Project & documents
| Tool | Purpose |
| --- | --- |
| `easyeda_get_context` | Active project/board/PCB/schematic/page |
| `easyeda_list_projects` | Projects across teams and folders |
| `easyeda_open_project` | Open by UUID (may discard unsaved work) |
| `easyeda_list_documents` | Schematics, pages, PCBs, boards, panels |
| `easyeda_open_document` / `easyeda_close_document` | Tab management |
| `easyeda_save_document` | Save active PCB/schematic |
| `easyeda_create_board` / `_schematic` / `_schematic_page` / `_pcb` | Create documents |
| `easyeda_create_project` / `_folder` / `_panel` | Create workspace/project structure |
| `easyeda_delete_document` / `easyeda_rename_document` / `easyeda_copy_document` | Board/PCB/schematic/page/panel lifecycle |
| `easyeda_reorder_schematic_pages` | Page order |
| `easyeda_delete_folder` / `easyeda_move_to_folder` | Folder and project placement |
### Schematic
| Tool | Purpose |
| --- | --- |
| `easyeda_sch_list_components` | List with designator/device/attributes |
| `easyeda_sch_get_component` | Full state + pins |
| `easyeda_sch_place_component` | Place by UUID, LCSC part or keyword |
| `easyeda_sch_update_components` | Batch position/rotation/attributes |
| `easyeda_sch_delete_components` | Delete (confirm) |
| `easyeda_sch_list_wires` / `easyeda_sch_create_wire` | Wires |
| `easyeda_sch_delete_wires` | Delete wires (confirm) |
| `easyeda_sch_list_buses` / `easyeda_sch_create_bus` | Buses |
| `easyeda_sch_list_pins` / `easyeda_sch_create_pin` | Free pins |
| `easyeda_sch_list_attributes` / `easyeda_sch_create_net_label` | Labels and fields |
| `easyeda_sch_list_nets` / `easyeda_sch_get_netlist` | Nets and netlist |
| `easyeda_sch_run_erc` | Electrical rule check |
### PCB
| Tool | Purpose |
| --- | --- |
| `easyeda_pcb_get_board_info` | Metadata, copper layers, primitive counts |
| `easyeda_pcb_list_components` / `easyeda_pcb_get_component` | Components |
| `easyeda_pcb_place_component` | Place a footprint by UUID/LCSC part/keyword |
| `easyeda_pcb_update_components` | Batch attributes, layer, rotation, designator |
| `easyeda_pcb_move_components` | Batch move/rotate/layer (one undo group) |
| `easyeda_pcb_delete_components` | Delete (confirm) |
| `easyeda_pcb_create_track` | Polyline track on a net/layer |
| `easyeda_pcb_create_via` | Via |
| `easyeda_pcb_create_region` | Region/keepout with rule types |
| `easyeda_pcb_create_text` / `easyeda_pcb_create_fill` | Text and copper fill primitives |
| `easyeda_pcb_create_arc` / `easyeda_pcb_create_polyline` | Arc and polyline copper |
| `easyeda_pcb_create_dimension` / `easyeda_pcb_create_image` | Dimensions and images |
| `easyeda_pcb_list_attributes` | Designator/value attribute primitives |
| `easyeda_pcb_delete_primitives` | Delete line/via/pad/region/fill/text/… (confirm) |
| `easyeda_pcb_list_primitives` | line/via/pad/region/fill/text/dimension/arc/polyline/image/pour/poured/component |
| `easyeda_pcb_get_primitives_in_region` | Spatial query |
| `easyeda_pcb_list_nets` | Detailed net info |
### Copper, layers, pours
| Tool | Purpose |
| --- | --- |
| `easyeda_pcb_list_layers` | All layers with id/name/type/color/visibility |
| `easyeda_pcb_get_stackup` | Stackup + physical configurations |
| `easyeda_pcb_set_stackup` | Overwrite/save a physical stackup (reorder build-up) |
| `easyeda_pcb_set_copper_layer_count` | 2/4/6/… (confirm) |
| `easyeda_pcb_create_custom_layer` / `_update_layer` / `_delete_layer` | Custom layers |
| `easyeda_pcb_set_layer_visibility` | Show/hide layers |
| `easyeda_pcb_list_pours` | Pour borders |
| `easyeda_pcb_create_pour` | Net, layer, polygon, fill method, priority, thermal |
| `easyeda_pcb_update_pour` / `easyeda_pcb_delete_pours` | Modify/delete |
| `easyeda_pcb_rebuild_pours` | Recompute poured copper |
| `easyeda_pcb_set_pad_thermal` | Thermal relief per net/pad |
### DRC / ERC rules
| Tool | Purpose |
| --- | --- |
| `easyeda_pcb_get_drc_rules` | Raw config + flattened `{path,value}` leaves |
| `easyeda_pcb_set_drc_rules` | Deep-merge patch and/or exact path patch + read-back |
| `easyeda_pcb_set_rule_value` | One value by path or path regex |
| `easyeda_pcb_set_track_width` | Convenience: track width (mm/mil) |
| `easyeda_pcb_set_clearance` | Convenience: clearance (mm/mil) |
| `easyeda_pcb_list_net_classes` / `easyeda_pcb_create_net_class` | Net classes |
| `easyeda_pcb_net_class_manage` | Add/remove nets, rename, delete a class |
| `easyeda_pcb_differential_pairs` | List/create/delete differential pairs |
| `easyeda_pcb_equal_length_groups` | Equal-length net groups |
| `easyeda_pcb_rule_configurations` | List/get/rename/delete/set-default configurations |
| `easyeda_pcb_run_drc` / `easyeda_pcb_get_drc_result` | Detailed DRC results |
### Libraries
| Tool | Purpose |
| --- | --- |
| `easyeda_lib_list_libraries` | Libraries and their UUIDs |
| `easyeda_lib_search_devices` | Keyword search |
| `easyeda_lib_search_by_supplier_id` | LCSC/JLC part lookup |
| `easyeda_lib_resolve_device` | Placement-ready `{libraryUuid, deviceUuid}` |
| `easyeda_lib_get_device` | Device details |
### Exports
`easyeda_export_gerber`, `easyeda_export_bom`, `easyeda_export_cpl`,
`easyeda_export_pdf`, `easyeda_export_netlist`, `easyeda_export_3d`,
`easyeda_export_dxf`.
Files are written to `EASYEDA_MCP_EXPORT_DIR` (default `./easyeda-export`) or the
`outputDir` argument. The response contains absolute paths and byte sizes.
### Selection & navigation
`easyeda_get_selection`, `easyeda_select_primitives`, `easyeda_clear_selection`,
`easyeda_highlight_net`, `easyeda_zoom`, `easyeda_focus_primitives`.
---
## Units
| Domain | Internal unit | Conversion |
| --- | --- | --- |
| PCB | 1 mil (0.001 in) | `mm = mil × 0.0254` |
| Schematic | 0.01 in (10 mil) | `mm = units × 0.254` |
Tools accept `*Mm` fields (`xMm`, `widthMm`, `clearanceMm`, `pointsMm`,
`regionMm`, `spacingMm`, …) and convert for you. Raw fields (`x`, `width`,
`points`, `polygon` with `units: "mil"`) use internal units.
DRC rule configurations are opaque. EasyEDA stores rule lengths in mil in
practice; `easyeda_pcb_set_rule_value` defaults to mil and lets you pass
`ruleUnits: "mm"` if your configuration differs. Always dry-run first.
---
## Example prompts
**Copper pour with clearance and thermal relief**
> Add a solid GND pour on the top layer over the board outline, priority 1,
> 0.2 mm clearance, thermal relief with 0.3 mm spokes and 0.3 mm gap.
```jsonc
// easyeda_pcb_create_pour
{
"net": "GND",
"layer": "top",
"polygon": { "type": "rect", "x": 0, "y": 0, "width": 80, "height": 60 },
"units": "mm",
"fillMethod": "solid",
"priority": 1,
"name": "GND_TOP",
"thermalRelief": { "connectionMethod": "Divergent", "spacingMm": 0.3, "lineWidthMm": 0.3 },
"clearanceMm": 0.2,
"confirm": true
}
```
**Change the default track width and re-run DRC**
```jsonc
// 1. preview
{ "widthMm": 0.25, "dryRun": true }
// 2. apply
{ "widthMm": 0.25, "confirm": true }
// 3. re-check
{ "includeGroups": true }
```
**Move decoupling capacitors near their IC power pins**
The agent lists components (`easyeda_pcb_list_components`), reads pads and nets
(`easyeda_pcb_get_component`), computes offsets, then calls
`easyeda_pcb_move_components` once for the whole batch. The batch is a single
undo group.
**Export a fabrication package**
> Export Gerbers, BOM and CPL to ./out.
Calls `easyeda_export_gerber`, `easyeda_export_bom`, `easyeda_export_cpl` with
`outputDir: "./out"`.
**Arbitrary API access**
```jsonc
// easyeda_run_script
{
"code": "const pcb = await eda.dmt_Pcb.getCurrentPcbInfo(); const layers = await eda.pcb_Layer.getAllLayers(); return { pcb, layers };"
}
```
**Any official method, without writing JS**
```jsonc
// 1. discover the exact signature
{ "namespace": "pcb_Drc", "method": "checkDetailed" } // easyeda_describe_method
// 2. call it, with enums and layers resolved for you
{
"namespace": "pcb_Layer",
"method": "setLayerVisible",
"args": [[{ "$enum": "EPCB_LayerId.TOP" }]],
"confirm": true
}
// 3. instance methods on one primitive (setState_* applies automatically)
{
"namespace": "pcb_PrimitivePad",
"primitiveId": "<pad id>",
"method": "setState_HeatWelding",
"args": [{ "connectionMethod": "Divergent", "divergenceSpacing": 12, "divergenceLineWidth": 8, "divergenceAngle": 45 }],
"confirm": true
}
```
---
## CLI
```
easyeda-pro-mcp [options] # MCP over stdio
easyeda-pro-mcp doctor [options] # diagnostics
```
| Option | Meaning |
| --- | --- |
| `--port <spec>` | `49620`, `49620-49629`, or `49620,49700` |
| `--host <host>` | Bind host (loopback only unless `--allow-remote`) |
| `--token <secret>` | Require the same token from the extension |
| `--bridge-url <url>` | Attach to an existing bridge (`http://` or `ws://`) |
| `--export-dir <dir>` | Export destination |
| `--timeout <ms>` | Default execution timeout |
| `--read-only` | Block every mutating tool |
| `--no-auto-start` | Only attach, never host a bridge |
| `--log-level <level>` | `silent`, `error`, `warn`, `info`, `debug` |
Environment equivalents are listed in `--help`.
### Multiple MCP clients
The first server binds a port in 49620-49629 and hosts the bridge. Later servers
probe the range, find the existing bridge and attach over `/agent`, so every
client sees the same editor windows.
### Official Run API Gateway compatibility
If the official **Run API Gateway** extension is installed instead of this one,
the server detects `service: "easyeda-bridge"` and uses the official HTTP
`/execute` endpoint. Typed tools still work; console logs are not available in
that mode.
---
## Architecture
See [`docs/ARCHITECTURE.md`](./docs/ARCHITECTURE.md).
Highlights:
- **Snippets, not a giant RPC enum.** Typed tools are TypeScript functions
stringified and executed in the editor. They are unit-tested against a mock
`eda` object, so closure/serialization bugs are caught before release.
- **Per-window serialization.** Editor mutations never interleave.
- **Batch undo groups.** PCB batch edits use `beginCommandGroup`/`commitCommandGroup`.
- **Rich serialization.** Primitives become `getState_*` snapshots; `File`/`Blob`
exports become base64 and are written to disk by the server; cycles, depth and
size are bounded.
- **Permission-aware.** The extension probes the external-interaction permission and
reports it in **Status…**.
---
## Development
```bash
npm ci # reproducible install (CI uses this)
npm run build # API catalog + server (tsc) + extension (esbuild)
npm test # snippets, bridge, client, docs, catalog coverage, MCP surface, e2e
npm run typecheck
npm run typecheck:extension
npm run package:extension # -> dist/*.eext
npm run check:extension-package # validate the archive
```
`npm run build` runs `build:docs` first, so a fresh clone needs no extra steps.
### Coverage guarantee
`npm run build:docs` generates `docs/api-catalog.json` from the vendored official
reference: every callable namespace, every method with parsed parameters, and
every enum. `test/api-coverage.test.mjs` then invokes **all 846 methods** through
the dispatcher and asserts none are unreachable. If an EasyEDA release adds a
method, refreshing the vendored docs and rebuilding makes it callable with no
code changes.
Project layout:
```
src/ MCP server (TypeScript)
bridge/ WebSocket bridge, discovery, client, decoding
runtime/ snippet runner + typed snippets per domain
tools/ MCP tool registrations
docs/ runtime API doc lookup
shared/ protocol, serialization, helpers (server + extension)
extension/ EasyEDA Pro extension source + extension.json
docs/api/ vendored official API reference (MIT)
scripts/ build, package, docs index, vendoring
test/ node:test suites
examples/ MCP client configs
```
To refresh the API reference:
```bash
npm run vendor:api-docs
npm run build:docs
```
---
## Troubleshooting
| Symptom | Fix |
| --- | --- |
| `No EasyEDA bridge is available` | Install the `.eext`, tick **Allow interactive with external** (Config tab), check **MCP Bridge → Status…** |
| `No EasyEDA window is connected` | The server is running but the extension has not registered; click **Reconnect** |
| `CONFIRMATION_REQUIRED` | Re-run with `confirm: true` (dry-run first where available) |
| `READ_ONLY` | Server started with `--read-only` / `EASYEDA_MCP_READ_ONLY=1` |
| Timeouts on DRC/pour rebuild | Pass a larger `timeoutMs`; large boards take minutes |
| `… is not a function` | EasyEDA API changed; look it up with `easyeda_search_api` |
| Port range busy | Another server hosts the bridge; this one attaches automatically. `doctor` shows where |
| Token mismatch | Set the same token in the extension menu **Set Bridge Token…** |
Logs go to **stderr** (`--log-level debug`). `stdout` is reserved for MCP.
---
## License
MIT. See [`LICENSE`](./LICENSE) and [`NOTICE`](./NOTICE) for attribution to
EasyEDA's Apache-2.0 Run API Gateway and MIT API reference.
Read [`SAFETY.md`](./SAFETY.md) before using this on a production design.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues