@intelligentelectron/pcb-lens 1.3.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/README.md +113 -63
  3. package/dist/cli/args.d.ts +16 -0
  4. package/dist/cli/args.d.ts.map +1 -0
  5. package/dist/cli/args.js +29 -0
  6. package/dist/cli/args.js.map +1 -0
  7. package/dist/cli/commands.d.ts +7 -1
  8. package/dist/cli/commands.d.ts.map +1 -1
  9. package/dist/cli/commands.js +47 -12
  10. package/dist/cli/commands.js.map +1 -1
  11. package/dist/cli/query.d.ts +68 -0
  12. package/dist/cli/query.d.ts.map +1 -0
  13. package/dist/cli/query.js +213 -0
  14. package/dist/cli/query.js.map +1 -0
  15. package/dist/cli/skill.d.ts +18 -0
  16. package/dist/cli/skill.d.ts.map +1 -0
  17. package/dist/cli/skill.js +127 -0
  18. package/dist/cli/skill.js.map +1 -0
  19. package/dist/cli/updater.d.ts +10 -2
  20. package/dist/cli/updater.d.ts.map +1 -1
  21. package/dist/cli/updater.js +31 -19
  22. package/dist/cli/updater.js.map +1 -1
  23. package/dist/cli/version.d.ts +1 -0
  24. package/dist/cli/version.d.ts.map +1 -1
  25. package/dist/cli/version.js +1 -0
  26. package/dist/cli/version.js.map +1 -1
  27. package/dist/index.d.ts +7 -5
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +31 -11
  30. package/dist/index.js.map +1 -1
  31. package/dist/server.d.ts.map +1 -1
  32. package/dist/server.js +6 -13
  33. package/dist/server.js.map +1 -1
  34. package/dist/tools/export-cadence-constraints.d.ts +5 -2
  35. package/dist/tools/export-cadence-constraints.d.ts.map +1 -1
  36. package/dist/tools/export-cadence-constraints.js +14 -17
  37. package/dist/tools/export-cadence-constraints.js.map +1 -1
  38. package/dist/tools/export-cadence-ipc2581.d.ts +9 -2
  39. package/dist/tools/export-cadence-ipc2581.d.ts.map +1 -1
  40. package/dist/tools/export-cadence-ipc2581.js +18 -21
  41. package/dist/tools/export-cadence-ipc2581.js.map +1 -1
  42. package/dist/tools/get-constraints.d.ts +5 -2
  43. package/dist/tools/get-constraints.d.ts.map +1 -1
  44. package/dist/tools/get-constraints.js +14 -17
  45. package/dist/tools/get-constraints.js.map +1 -1
  46. package/dist/tools/get-pcb-component.d.ts +9 -2
  47. package/dist/tools/get-pcb-component.d.ts.map +1 -1
  48. package/dist/tools/get-pcb-component.js +16 -20
  49. package/dist/tools/get-pcb-component.js.map +1 -1
  50. package/dist/tools/get-pcb-metadata.d.ts +4 -2
  51. package/dist/tools/get-pcb-metadata.d.ts.map +1 -1
  52. package/dist/tools/get-pcb-metadata.js +11 -13
  53. package/dist/tools/get-pcb-metadata.js.map +1 -1
  54. package/dist/tools/get-pcb-net.d.ts +9 -2
  55. package/dist/tools/get-pcb-net.d.ts.map +1 -1
  56. package/dist/tools/get-pcb-net.js +18 -20
  57. package/dist/tools/get-pcb-net.js.map +1 -1
  58. package/dist/tools/index.d.ts +9 -0
  59. package/dist/tools/index.d.ts.map +1 -0
  60. package/dist/tools/index.js +20 -0
  61. package/dist/tools/index.js.map +1 -0
  62. package/dist/tools/registry.d.ts +15 -0
  63. package/dist/tools/registry.d.ts.map +1 -0
  64. package/dist/tools/registry.js +7 -0
  65. package/dist/tools/registry.js.map +1 -0
  66. package/package.json +3 -2
package/CHANGELOG.md CHANGED
@@ -1,10 +1,28 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to this project will be documented in this file.
3
+ This file records releases through v1.4.0. Later changelogs are generated from merged
4
+ pull requests and published with each [GitHub Release](https://github.com/IntelligentElectron/pcb-lens/releases).
4
5
 
5
6
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
7
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
8
 
9
+ ## [1.4.0] - 2026-11-17
10
+
11
+ ### Added
12
+
13
+ - Every MCP tool is also a command: `pcb-lens <tool> [file] --flag value ...` prints the tool's JSON result, with flags built from the tool's own schema; `pcb-lens <tool> --help` gives its description and flags. Exit 1 on a result with an `error` field, 2 on a usage error. Commands are accepted as words too (`pcb-lens update`, `pcb-lens upgrade`). See `docs/cli.md`
14
+ - Agent plugin for Claude Code, Codex, Cursor and Copilot (`plugins/pcb-lens`): connects the MCP server from the binary on PATH and carries a skill, generated from the tool registry, for the command line where MCP is unavailable
15
+
16
+ ### Changed
17
+
18
+ - Each Mac installs and updates to the binary for its own CPU, `pcb-lens-darwin-arm64` or `pcb-lens-darwin-x64`, instead of a universal binary that carries both. An x64 binary running under Rosetta on Apple Silicon updates itself to the arm64 one. Releases still publish `pcb-lens-darwin-universal` for installs up to v1.3.x, whose next update moves them to the per-architecture binary
19
+ - The installer adds the binary's folder to the login profile as well as the shell's startup file, so apps started outside a terminal (the Claude desktop app) find it, and it ends by naming the plugin to install
20
+
21
+ ### Removed
22
+
23
+ - The Claude Desktop extension (`pcb-lens.mcpb`) and its `manifest.json`: the plugin connects the server in Claude Code, the Claude desktop app's Code tab, Codex, Cursor and Copilot
24
+ - The `--no-update` line in `--help`, a flag the binary never implemented
25
+
8
26
  ## [1.3.0] - 2026-11-17
9
27
 
10
28
  ### Added
package/README.md CHANGED
@@ -1,19 +1,23 @@
1
1
  # PCB Lens MCP Server
2
2
 
3
- The **PCB Lens MCP Server** gives AI agents the tools to query and review your PCB layouts, enabling physical design review through natural conversations.
3
+ The **PCB Lens MCP Server** gives AI agents the tools to understand and review your PCB layouts, for physical design reviews through natural conversations.
4
4
 
5
- It works with any board layout in IPC-2581 format, exported from any EDA tool that supports the standard.
5
+ It reads IPC-2581 layouts from any EDA tool, and Cadence Allegro boards and constraint files directly on macOS, Linux, and Windows, with no Cadence installation and no EDA license required.
6
6
 
7
7
  ## Supported Formats
8
8
 
9
9
  | Format | Input Files | Description |
10
10
  |--------|------------|-------------|
11
- | IPC-2581 | `.xml` | IPC-2581 XML files (RevA, RevB, RevC) from any compliant EDA tool |
12
- | Cadence TCFX | `.tcfx` | Constraint XML exported from Cadence Allegro: physical and spacing rules, net classes, stackup, regions |
13
- | Cadence Allegro | `.brd` | Native board files. Constraints are read directly on any OS ([format notes](docs/allegro-brd-format.md)); IPC-2581 and `.tcfx` export needs Windows and a Cadence SPB installation |
11
+ | Cadence Allegro | `.brd` | Reads the binary board directly: the live physical and electrical constraint sets, net classes, match groups, diff pairs, regions, per-net assignments and the stackup (Allegro 17.x), and the Constraint Manager archives the board embeds. See [the Allegro .brd format](docs/allegro-brd-format.md) |
14
12
  | Cadence Constraint Manager | `.dcf` | Constraint database of a schematic or board |
13
+ | Cadence TCFX | `.tcfx` | Constraint XML exported from Allegro: physical and spacing rules, net classes, stackup, regions |
14
+ | IPC-2581 | `.xml` | RevA, RevB and RevC files from any compliant EDA tool: stackup, component placement and pads, net connectivity, routing and vias |
15
15
 
16
- ## Native Install (Recommended)
16
+ ## Install
17
+
18
+ Installing takes two steps: the `pcb-lens` binary, then the plugin for your agent. The plugin connects the MCP server to the agent, so there is no configuration to write.
19
+
20
+ ### 1. Install the binary
17
21
 
18
22
  **macOS / Linux:**
19
23
 
@@ -27,116 +31,162 @@ curl -fsSL https://raw.githubusercontent.com/IntelligentElectron/pcb-lens/main/i
27
31
  irm https://raw.githubusercontent.com/IntelligentElectron/pcb-lens/main/install.ps1 | iex
28
32
  ```
29
33
 
30
- Why use the native installer:
31
- - **No dependencies** — standalone binary, no Node.js required
32
- - **Auto-updates** — checks for updates on startup
33
- - **Signed binaries** — macOS binaries are notarized by Apple
34
+ The installer provides:
35
+ - **No dependencies**: a standalone binary, with no Node.js required
36
+ - **Auto-updates**: the binary checks for updates on startup; `pcb-lens update` updates it on demand
37
+ - **Signed binaries**: macOS binaries are notarized by Apple
34
38
 
35
- The installer downloads two files:
39
+ It places the binary in the `bin/` folder of `~/Library/Application Support/pcb-lens/` (macOS), `~/.local/share/pcb-lens/` (Linux) or `%LOCALAPPDATA%\pcb-lens\` (Windows), and adds that folder to your PATH in both your shell's startup file and its login profile, so apps started outside a terminal, such as the Claude desktop app, find it too. Restart your agent afterwards.
36
40
 
37
- 1. **Binary** - For CLI usage and manual MCP client configuration
38
- 2. **Claude Desktop extension** (.mcpb) - For easy Claude Desktop integration
41
+ <details>
42
+ <summary>Install with npm instead</summary>
39
43
 
40
- | Platform | Install Directory |
41
- |----------|-------------------|
42
- | macOS | `~/Library/Application Support/pcb-lens/` |
43
- | Linux | `~/.local/share/pcb-lens/` |
44
- | Windows | `%LOCALAPPDATA%\pcb-lens\` |
44
+ ```bash
45
+ npm install -g @intelligentelectron/pcb-lens
46
+ ```
45
47
 
46
- ### Update
48
+ Requires Node.js 24+. Update with `npm update -g @intelligentelectron/pcb-lens`.
47
49
 
48
- The server checks for updates on startup. To update manually:
50
+ Install the binary one way only: the plugin runs the first `pcb-lens` on your PATH.
51
+
52
+ </details>
53
+
54
+ ### 2. Install the plugin
55
+
56
+ #### Claude Code
49
57
 
50
- ```bash
51
- pcb-lens --update
58
+ ```
59
+ /plugin marketplace add IntelligentElectron/pcb-lens
60
+ /plugin install pcb-lens@pcb-lens
52
61
  ```
53
62
 
54
- ## Alternative: Install via npm
63
+ Local sessions in the Code tab of the [Claude desktop app](https://claude.ai/download) use Claude Code's plugins, so the server is available there too.
55
64
 
56
- For developers who prefer npm:
65
+ #### OpenAI Codex
57
66
 
58
67
  ```bash
59
- npm install -g @intelligentelectron/pcb-lens
68
+ codex plugin marketplace add IntelligentElectron/pcb-lens --sparse .agents/plugins --sparse plugins
69
+ codex plugin add pcb-lens@pcb-lens
60
70
  ```
61
71
 
62
- Or use with npx (no installation required):
72
+ The `--sparse` paths fetch only the plugin; Codex otherwise clones the whole repository, test fixtures included. The plugin works in the Codex CLI and the Codex app.
73
+
74
+ Then ask the agent to review a layout, trace a net, or read a board's constraints.
75
+
76
+ #### Other agents
77
+
78
+ <details>
79
+ <summary>Cursor</summary>
80
+
81
+ Open **Customize**, choose **Browse Marketplace**, then **Add Marketplace → Import from GitHub**. Enter `IntelligentElectron/pcb-lens` and add the `pcb-lens` plugin.
82
+
83
+ </details>
84
+
85
+ <details>
86
+ <summary>GitHub Copilot CLI</summary>
63
87
 
64
88
  ```bash
65
- npx @intelligentelectron/pcb-lens --help
89
+ copilot plugin marketplace add IntelligentElectron/pcb-lens
90
+ copilot plugin install pcb-lens@pcb-lens
66
91
  ```
67
92
 
68
- Requires Node.js 20+.
93
+ </details>
69
94
 
70
- To update:
95
+ <details>
96
+ <summary>Turn the plugin on for everyone who clones a project</summary>
71
97
 
72
- ```bash
73
- npm update -g @intelligentelectron/pcb-lens
98
+ Add this to the project's `.claude/settings.json`:
99
+
100
+ ```json
101
+ {
102
+ "extraKnownMarketplaces": {
103
+ "pcb-lens": {
104
+ "source": { "source": "github", "repo": "IntelligentElectron/pcb-lens" }
105
+ }
106
+ },
107
+ "enabledPlugins": { "pcb-lens@pcb-lens": true }
108
+ }
74
109
  ```
75
110
 
76
- ## Connect the MCP with your favorite AI tool
111
+ and this to the project's `.codex/config.toml`:
77
112
 
78
- After installing the MCP with one of the methods above, you can connect it to your AI agent of choice.
113
+ ```toml
114
+ [marketplaces.pcb-lens]
115
+ source_type = "git"
116
+ source = "https://github.com/IntelligentElectron/pcb-lens.git"
117
+ sparse_paths = [".agents/plugins", "plugins"]
118
+
119
+ [plugins."pcb-lens@pcb-lens"]
120
+ enabled = true
121
+ ```
79
122
 
80
- ### Claude Desktop
123
+ Each person still installs the binary once.
81
124
 
82
- 1. Download the [Claude Desktop app](https://claude.ai/download)
83
- 2. Open Claude Desktop and go to **Settings** (gear icon)
84
- 3. Under **Desktop app**, click **Extensions**
85
- 4. Click **Advanced settings**
86
- 5. In the **Extension Developer** section, click **Install Extension...**
87
- 6. Navigate to your install directory and select `pcb-lens.mcpb`:
88
- - **macOS**: `~/Library/Application Support/pcb-lens/pcb-lens.mcpb`
89
- - **Windows**: `%LOCALAPPDATA%\pcb-lens\pcb-lens.mcpb`
125
+ </details>
90
126
 
91
- The extension will be available immediately in your conversations.
127
+ <details>
128
+ <summary>Moving from a server you registered by hand</summary>
92
129
 
93
- ### Claude Code
130
+ If you registered the server yourself before, remove that registration so the agent does not run two copies:
94
131
 
95
- Install [Claude Code](https://docs.anthropic.com/en/docs/claude-code), then run:
132
+ ```bash
133
+ claude mcp remove --scope user pcb-lens
134
+ ```
96
135
 
97
136
  ```bash
98
- claude mcp add --scope user pcb-lens -- pcb-lens
137
+ codex mcp remove pcb-lens
99
138
  ```
100
139
 
101
- ### OpenAI Codex
140
+ </details>
141
+
142
+ <details>
143
+ <summary>The command line, for agents without MCP</summary>
144
+
145
+ Every MCP tool is also a shell command, for an agent in a sandbox or container that cannot connect an MCP server:
102
146
 
103
- Install [OpenAI Codex](https://developers.openai.com/codex/cli/), then run:
147
+ ```bash
148
+ pcb-lens get_pcb_net board.xml --pattern '^DDR_D'
149
+ pcb-lens get_constraints board.brd --section BrdStackup
150
+ ```
151
+
152
+ The plugin carries a skill that teaches an agent those commands, their flags and exit codes; the agent uses it only when the MCP server is not connected. Agents that read [Agent Skills](https://agentskills.io) can install the skill alone through the GitHub CLI:
104
153
 
105
154
  ```bash
106
- codex mcp add pcb-lens -- pcb-lens
155
+ gh skill install IntelligentElectron/pcb-lens pcb-lens --agent github-copilot --scope user
107
156
  ```
108
157
 
109
- ## Supported Platforms
158
+ See [docs/cli.md](docs/cli.md) for the command line itself.
110
159
 
111
- | Platform | Binary |
112
- |----------|--------|
113
- | macOS (Universal) | `pcb-lens-darwin-universal` |
114
- | Linux (x64) | `pcb-lens-linux-x64` |
115
- | Linux (ARM64) | `pcb-lens-linux-arm64` |
116
- | Windows (x64) | `pcb-lens-windows-x64.exe` |
160
+ </details>
117
161
 
118
162
  ## Observability (OpenTelemetry)
119
163
 
120
- The server can emit [OpenTelemetry](https://opentelemetry.io/) **traces, metrics, and logs** for every tool call — a span, the `tool.calls`/`tool.duration`/`tool.errors` metrics, and a correlated log record — so you can see which tools are used, how long they take, and what fails. It is vendor-neutral and speaks OTLP, working with any compatible backend (OpenTelemetry Collector, Jaeger, Tempo, Prometheus, Honeycomb, Datadog, a managed cloud service, etc.).
164
+ The server can emit [OpenTelemetry](https://opentelemetry.io/) **traces, metrics, and logs** for every tool call, which report what is used, how long it takes, and what fails. Any OTLP-compatible backend receives them (an OpenTelemetry Collector, Jaeger, Tempo, Prometheus, Honeycomb, Datadog, or a managed cloud tracing service).
121
165
 
122
- **Disabled by default**, with zero overhead. Turn it on purely with the standard `OTEL_*` environment variables — point `OTEL_EXPORTER_OTLP_ENDPOINT` at your backend (and optionally set `OTEL_SERVICE_NAME`); no code changes. Telemetry never affects tool results.
166
+ OpenTelemetry is **disabled by default** and is enabled and configured through the standard `OTEL_*` environment variables, with no code changes.
123
167
 
124
- See **[docs/observability.md](docs/observability.md)** for the full signal reference, configuration, and integration guide.
168
+ See **[Observability (OpenTelemetry)](docs/observability.md)** for setup, configuration, and the full list of emitted spans, metrics, and logs.
125
169
 
126
170
  ## Documentation
127
171
 
128
- See [docs/](docs/README.md) for API documentation and response schemas.
172
+ See [docs/](docs/README.md) for API documentation, response schemas and [supported platforms](docs/README.md#supported-platforms), [docs/cli.md](docs/cli.md) for the binary's command line, and [docs/allegro-brd-format.md](docs/allegro-brd-format.md) for the Allegro board format as pcb-lens reads it.
129
173
 
130
174
  See [CONTRIBUTING.md](CONTRIBUTING.md) for development guidelines.
131
175
 
132
- ---
176
+ ## Privacy Policy
133
177
 
134
- ## About
178
+ The server runs on your machine and sends the author nothing. It keeps a local usage log (`telemetry.jsonl`) in its install directory, which leaves the machine only if you pack it with `pcb-lens export-telemetry` and share it. Its only network call is the update check against this repository's GitHub releases.
135
179
 
136
- Created by **Valentino Zegna**
180
+ ## About
137
181
 
138
182
  This project is hosted on GitHub under the [IntelligentElectron](https://github.com/IntelligentElectron) organization.
139
183
 
184
+ PCB Lens MCP Server is an original work by [Valentino Zegna](https://www.linkedin.com/in/valentinozegna).
185
+
186
+ ## Acknowledgments
187
+
188
+ The Allegro `.brd` reader's file header, string table and block framing follow the notes of KiCad's Allegro importer ([FORMAT.md](https://github.com/KiCad/kicad-source-mirror/blob/master/pcbnew/pcb_io/allegro/FORMAT.md)). Their work made reading the board database directly possible.
189
+
140
190
  ## License
141
191
 
142
192
  Apache License 2.0 - see [LICENSE](LICENSE)
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Command-line argument normalization.
3
+ *
4
+ * Every command is accepted both as a word and as a flag: `pcb-lens
5
+ * update` and `pcb-lens --update` are the same call, and so is
6
+ * `upgrade`, an alias of `update`. The rest of the program reads the flag form
7
+ * of the command's own name, so this rewrites every other spelling into it
8
+ * before anything else looks at the arguments.
9
+ */
10
+ /** Every command the binary understands, in its word form. */
11
+ export declare const COMMANDS: readonly ["version", "help", "update", "uninstall", "export-telemetry"];
12
+ /** Other spellings of a command, each rewritten to the command it names. */
13
+ export declare const ALIASES: Record<string, (typeof COMMANDS)[number]>;
14
+ /** Rewrite command words to their flag form. Anything that is not a command word is left as it is. */
15
+ export declare const normalizeCliArgs: (args: readonly string[]) => string[];
16
+ //# sourceMappingURL=args.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,8DAA8D;AAC9D,eAAO,MAAM,QAAQ,yEAA0E,CAAC;AAIhG,4EAA4E;AAC5E,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAE7D,CAAC;AASF,sGAAsG;AACtG,eAAO,MAAM,gBAAgB,GAAI,MAAM,SAAS,MAAM,EAAE,KAAG,MAAM,EAI7D,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Command-line argument normalization.
3
+ *
4
+ * Every command is accepted both as a word and as a flag: `pcb-lens
5
+ * update` and `pcb-lens --update` are the same call, and so is
6
+ * `upgrade`, an alias of `update`. The rest of the program reads the flag form
7
+ * of the command's own name, so this rewrites every other spelling into it
8
+ * before anything else looks at the arguments.
9
+ */
10
+ /** Every command the binary understands, in its word form. */
11
+ export const COMMANDS = ["version", "help", "update", "uninstall", "export-telemetry"];
12
+ const COMMAND_SET = new Set(COMMANDS);
13
+ /** Other spellings of a command, each rewritten to the command it names. */
14
+ export const ALIASES = {
15
+ upgrade: "update",
16
+ };
17
+ /** The command a token names, as a word, or undefined when it names none. */
18
+ const commandOf = (token) => {
19
+ const word = token.startsWith("--") ? token.slice(2) : token;
20
+ if (COMMAND_SET.has(word))
21
+ return word;
22
+ return ALIASES[word];
23
+ };
24
+ /** Rewrite command words to their flag form. Anything that is not a command word is left as it is. */
25
+ export const normalizeCliArgs = (args) => args.map((token) => {
26
+ const command = commandOf(token);
27
+ return command === undefined ? token : `--${command}`;
28
+ });
29
+ //# sourceMappingURL=args.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,8DAA8D;AAC9D,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,CAAU,CAAC;AAEhG,MAAM,WAAW,GAAG,IAAI,GAAG,CAAS,QAAQ,CAAC,CAAC;AAE9C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,OAAO,GAA8C;IAChE,OAAO,EAAE,QAAQ;CAClB,CAAC;AAEF,6EAA6E;AAC7E,MAAM,SAAS,GAAG,CAAC,KAAa,EAAsB,EAAE;IACtD,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC7D,IAAI,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;AACvB,CAAC,CAAC;AAEF,sGAAsG;AACtG,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAuB,EAAY,EAAE,CACpE,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;IACjB,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IACjC,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC;AACxD,CAAC,CAAC,CAAC"}
@@ -1,6 +1,8 @@
1
1
  /**
2
- * CLI command handlers for --version, --help, --update, and --uninstall.
2
+ * CLI command handlers: --version, --help, --update, --uninstall, and every
3
+ * tool as a command (see query.ts).
3
4
  */
5
+ import type { AnyToolDefinition } from "../tools/index.js";
4
6
  /**
5
7
  * Print version information.
6
8
  */
@@ -25,4 +27,8 @@ export declare const handleUninstallCommand: () => Promise<void>;
25
27
  * Exports telemetry data as a zip file in the current working directory.
26
28
  */
27
29
  export declare const handleExportTelemetryCommand: () => Promise<void>;
30
+ /** Run a tool from the command line, printing its JSON result. */
31
+ export declare const handleQueryCommand: (tool: AnyToolDefinition, tokens: readonly string[]) => Promise<void>;
32
+ /** A first word that is neither a command nor a tool: say what is, and exit 2. */
33
+ export declare const handleUnknownCommand: (word: string) => void;
28
34
  //# sourceMappingURL=commands.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH;;GAEG;AACH,eAAO,MAAM,YAAY,QAAO,IAE/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,QAAO,IAsB5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,QAAa,OAAO,CAAC,IAAI,CAsCxD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,QAAa,OAAO,CAAC,IAAI,CAiC3D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,QAAa,OAAO,CAAC,IAAI,CAQjE,CAAC"}
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,YAAY,QAAO,IAE/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,QAAO,IAiC5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,QAAa,OAAO,CAAC,IAAI,CAsCxD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,QAAa,OAAO,CAAC,IAAI,CAiC3D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,QAAa,OAAO,CAAC,IAAI,CAQjE,CAAC;AAEF,kEAAkE;AAClE,eAAO,MAAM,kBAAkB,GAC7B,MAAM,iBAAiB,EACvB,QAAQ,SAAS,MAAM,EAAE,KACxB,OAAO,CAAC,IAAI,CAUd,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,KAAG,IAOnD,CAAC"}
@@ -1,5 +1,6 @@
1
1
  /**
2
- * CLI command handlers for --version, --help, --update, and --uninstall.
2
+ * CLI command handlers: --version, --help, --update, --uninstall, and every
3
+ * tool as a command (see query.ts).
3
4
  */
4
5
  import { existsSync, rmSync } from "node:fs";
5
6
  import { dirname } from "node:path";
@@ -9,6 +10,7 @@ import { checkForUpdate, performUpdate, isNpmInstall } from "./updater.js";
9
10
  import { getCurrentExecutablePath } from "./executable.js";
10
11
  import { confirm } from "./prompts.js";
11
12
  import { removeFromPath } from "./shell.js";
13
+ import { runQuery, toolList } from "./query.js";
12
14
  /**
13
15
  * Print version information.
14
16
  */
@@ -22,20 +24,31 @@ export const printHelp = () => {
22
24
  console.log(`
23
25
  ${BINARY_NAME} v${VERSION}
24
26
 
25
- MCP server for IPC-2581 PCB layout analysis.
27
+ Usage: ${BINARY_NAME} [options] [command]
26
28
 
27
- USAGE:
28
- ${BINARY_NAME} [OPTIONS]
29
+ MCP server for PCB layout review: IPC-2581 layouts, Allegro .brd boards and Cadence
30
+ constraint files. An MCP client runs the binary with no command and speaks to it over
31
+ stdio. Every MCP tool is also a command, for a shell or an agent without MCP:
29
32
 
30
- OPTIONS:
31
- --version, -v Print version and exit
32
- --help, -h Show this help message
33
- --update Check for and install updates
34
- --uninstall Remove binary and PATH entries
35
- --export-telemetry Export telemetry data as a zip file
36
- --no-update Disable auto-update check on startup
33
+ ${BINARY_NAME} <tool> [file] --flag value ...
34
+ ${BINARY_NAME} <tool> --help that tool's description and flags
37
35
 
38
- MORE INFO:
36
+ Tools:
37
+ ${toolList()}
38
+
39
+ Options:
40
+ -v, --version Output the version number
41
+ -h, --help Display help for command
42
+
43
+ Commands:
44
+ update|upgrade Check for updates and install if available
45
+ uninstall Remove the binary and its PATH entries
46
+ export-telemetry Export telemetry data as a zip file
47
+
48
+ A tool prints its result as JSON on stdout and exits 1 when the result has an error
49
+ field, 2 on a usage error.
50
+
51
+ More info:
39
52
  https://github.com/${GITHUB_REPO}
40
53
  `.trim());
41
54
  };
@@ -122,4 +135,26 @@ export const handleExportTelemetryCommand = async () => {
122
135
  process.exit(1);
123
136
  }
124
137
  };
138
+ /** Run a tool from the command line, printing its JSON result. */
139
+ export const handleQueryCommand = async (tool, tokens) => {
140
+ const outcome = await runQuery(tool, tokens, { isTTY: Boolean(process.stdout.isTTY) });
141
+ // A reader that has seen enough closes the pipe (`| head`); the rest of the
142
+ // output has nowhere to go, which is not a failure of the query.
143
+ process.stdout.on("error", (error) => {
144
+ if (error.code !== "EPIPE")
145
+ throw error;
146
+ });
147
+ if (outcome.stdout !== undefined)
148
+ process.stdout.write(`${outcome.stdout}\n`);
149
+ if (outcome.stderr !== undefined)
150
+ process.stderr.write(`${outcome.stderr}\n`);
151
+ process.exitCode = outcome.exitCode;
152
+ };
153
+ /** A first word that is neither a command nor a tool: say what is, and exit 2. */
154
+ export const handleUnknownCommand = (word) => {
155
+ process.stderr.write(`error: '${word}' is not a command or a tool.\n` +
156
+ `Tools (run '${BINARY_NAME} <tool> --help' for one's flags):\n${toolList()}\n` +
157
+ `Run '${BINARY_NAME} help' for the other commands.\n`);
158
+ process.exitCode = 2;
159
+ };
125
160
  //# sourceMappingURL=commands.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAS,EAAE;IACrC,OAAO,CAAC,GAAG,CAAC,GAAG,WAAW,KAAK,OAAO,EAAE,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAS,EAAE;IAClC,OAAO,CAAC,GAAG,CACT;EACF,WAAW,KAAK,OAAO;;;;;IAKrB,WAAW;;;;;;;;;;;uBAWQ,WAAW;CACjC,CAAC,IAAI,EAAE,CACL,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KA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AC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACvF,4EAA4E;IAC5E,iEAAiE;IACjE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAA4B,EAAE,EAAE;QAC1D,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;YAAE,MAAM,KAAK,CAAC;IAC1C,CAAC,CAAC,CAAC;IACH,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;IAC9E,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;IAC9E,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;AACtC,CAAC,CAAC;AAEF,kFAAkF;AAClF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAQ,EAAE;IACzD,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,WAAW,IAAI,iCAAiC;QAC9C,eAAe,WAAW,sCAAsC,QAAQ,EAAE,IAAI;QAC9E,QAAQ,WAAW,kCAAkC,CACxD,CAAC;IACF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The query command line: every registry tool as a subcommand under its MCP
3
+ * name, with flags named as its schema's arguments, which the MCP server
4
+ * registers too.
5
+ *
6
+ * pcb-lens get_pcb_net board.xml --pattern '^DDR_D'
7
+ * pcb-lens get_constraints --file board.brd --section BrdStackup
8
+ *
9
+ * The flags are built from each tool's schema, so the command line takes the
10
+ * same arguments as the MCP tool and applies the same defaults. A string or
11
+ * number flag takes the next token or `=value`; a value starting with a dash
12
+ * needs `=`. A boolean flag alone means true, and takes `true` or `false` after
13
+ * it or after `=`. An array flag repeats. The file the tool reads (`file` or
14
+ * `board`) may also come first, as a positional argument.
15
+ *
16
+ * The result is the tool's JSON on stdout, indented on a terminal and compact
17
+ * otherwise. A result with an `error` field exits 1; a usage error prints to
18
+ * stderr with the tool's usage line and exits 2.
19
+ */
20
+ import { type AnyToolDefinition } from "../tools/index.js";
21
+ export type FlagKind = "string" | "number" | "boolean" | "array";
22
+ export interface FlagSpec {
23
+ readonly name: string;
24
+ readonly kind: FlagKind;
25
+ readonly required: boolean;
26
+ readonly description?: string;
27
+ readonly default?: unknown;
28
+ }
29
+ /** A tool's flags, in its schema's order, from the schema's input JSON Schema. */
30
+ export declare const flagsOf: (tool: AnyToolDefinition) => FlagSpec[];
31
+ /** The argument naming the file a tool reads, which may come first without its flag. */
32
+ export declare const positionalOf: (tool: AnyToolDefinition) => string | undefined;
33
+ /** What a tool's command line asks for. */
34
+ export type ParsedQuery = {
35
+ readonly kind: "help";
36
+ } | {
37
+ readonly kind: "run";
38
+ readonly args: Record<string, unknown>;
39
+ } | {
40
+ readonly kind: "usage";
41
+ readonly message: string;
42
+ };
43
+ /**
44
+ * Parse the tokens after a tool's name. Errors name the flag and say how to
45
+ * write it; they are usage errors, and nothing runs.
46
+ */
47
+ export declare const parseQueryArgs: (tool: AnyToolDefinition, tokens: readonly string[]) => ParsedQuery;
48
+ /** One line naming the tool and its flags, required ones bare and the rest in brackets. */
49
+ export declare const usageLine: (tool: AnyToolDefinition) => string;
50
+ /** A tool's description and every flag, from the registry. */
51
+ export declare const toolHelp: (tool: AnyToolDefinition) => string;
52
+ /** The tools `--help` prints. */
53
+ export declare const toolList: () => string;
54
+ /** What a call prints and how it exits. */
55
+ export interface QueryOutcome {
56
+ readonly exitCode: 0 | 1 | 2;
57
+ readonly stdout?: string;
58
+ readonly stderr?: string;
59
+ /** Why the call failed, for telemetry. */
60
+ readonly errorMessage?: string;
61
+ }
62
+ /** Run a tool's command line. */
63
+ export declare const runQuery: (tool: AnyToolDefinition, tokens: readonly string[], options: {
64
+ isTTY: boolean;
65
+ }) => Promise<QueryOutcome>;
66
+ /** The registry tool a command-line word names, if any. */
67
+ export declare const toolNamed: (word: string | undefined) => AnyToolDefinition | undefined;
68
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/cli/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAO5E,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AAEjE,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAQD,kFAAkF;AAClF,eAAO,MAAM,OAAO,GAAI,MAAM,iBAAiB,KAAG,QAAQ,EAoBzD,CAAC;AAEF,wFAAwF;AACxF,eAAO,MAAM,YAAY,GAAI,MAAM,iBAAiB,KAAG,MAAM,GAAG,SACJ,CAAC;AAM7D,2CAA2C;AAC3C,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAChE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE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