@jlcpcb/mcp 0.1.0

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # @jlcpcb/mcp
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`cc44735`](https://github.com/l3wi/jlc-cli/commit/cc44735cc56191533f1a088101dfe2b368929048) Thanks [@l3wi](https://github.com/l3wi)! - Initial release of @jlcpcb packages for JLC/EasyEDA component sourcing and KiCad integration.
8
+ - **@jlcpcb/core**: Core library with API clients, converters, and services
9
+ - **@jlcpcb/cli**: Interactive terminal UI for component search and library management
10
+ - **@jlcpcb/mcp**: MCP server for Claude Desktop/Code integration
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [[`cc44735`](https://github.com/l3wi/jlc-cli/commit/cc44735cc56191533f1a088101dfe2b368929048)]:
15
+ - @jlcpcb/core@0.1.0
package/README.md ADDED
@@ -0,0 +1,241 @@
1
+ # jlc-mcp
2
+
3
+ MCP server for JLC/LCSC component sourcing and KiCad library conversion.
4
+
5
+ Search JLCPCB's parts database, fetch components as KiCad-compatible symbols and footprints, and manage organized component libraries - all through the Model Context Protocol.
6
+
7
+ ## Why LCSC?
8
+
9
+ **LCSC is JLC PCB's preferred supplier for assembly (PCBA).** Components with LCSC part numbers (e.g., C2040) are guaranteed to be available when ordering PCB assembly from JLCPCB.
10
+
11
+ - **Basic Parts Library**: Components marked as "Basic" have no extended part fee ($3 savings per unique part)
12
+ - **In-Stock Filtering**: Search only parts currently available for immediate assembly
13
+ - **Direct Integration**: Fetched components are ready for JLC assembly without manual library work
14
+
15
+ ## Features
16
+
17
+ - Search JLCPCB parts database with stock levels and pricing
18
+ - Fetch components directly to KiCad-compatible symbol/footprint format
19
+ - Category-based library organization (Resistors, Capacitors, ICs, etc.)
20
+ - Hybrid footprint strategy: standard packages use KiCad built-ins, custom packages are generated
21
+ - EasyEDA community library support for modules and breakouts
22
+ - 3D model downloads (STEP/OBJ formats)
23
+
24
+ ## Usage
25
+
26
+ ### Option 1: Quick Start (npx)
27
+
28
+ No installation required - run directly:
29
+
30
+ ```bash
31
+ npx -y jlc-mcp@latest
32
+ ```
33
+
34
+ **Claude Desktop configuration** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
35
+
36
+ ```json
37
+ {
38
+ "mcpServers": {
39
+ "jlc": {
40
+ "command": "npx",
41
+ "args": ["-y", "jlc-mcp@latest"]
42
+ }
43
+ }
44
+ }
45
+ ```
46
+
47
+ ### Option 2: Local Development
48
+
49
+ Clone and build:
50
+
51
+ ```bash
52
+ git clone https://github.com/anthropics/ai-eda.git
53
+ cd ai-eda/packages/jlc-mcp
54
+ bun install
55
+ bun run build
56
+ ```
57
+
58
+ **Claude Desktop configuration:**
59
+
60
+ ```json
61
+ {
62
+ "mcpServers": {
63
+ "jlc": {
64
+ "command": "node",
65
+ "args": ["/absolute/path/to/jlc-mcp/dist/index.js"]
66
+ }
67
+ }
68
+ }
69
+ ```
70
+
71
+ > **Note:** Restart Claude Desktop after modifying the configuration.
72
+
73
+ ## Tools Reference
74
+
75
+ ### Search & Discovery
76
+
77
+ | Tool | Description | Key Parameters |
78
+ |------|-------------|----------------|
79
+ | `component_search` | Search JLCPCB parts database | `query`, `in_stock`, `basic_only`, `limit` |
80
+ | `component_get` | Get detailed component info by LCSC ID | `lcsc_id` (e.g., "C2040") |
81
+
82
+ ### Library Management
83
+
84
+ | Tool | Description | Key Parameters |
85
+ |------|-------------|----------------|
86
+ | `library_fetch` | Fetch component and add to KiCad library | `lcsc_id`, `project_path`?, `include_3d`? |
87
+ | `library_get_symbol` | Get raw KiCad symbol data | `lcsc_id` |
88
+ | `library_get_footprint` | Get raw KiCad footprint data | `lcsc_id` |
89
+ | `library_get_3d_model` | Download 3D model | `uuid`, `format` |
90
+ | `library_update` | Initialize or regenerate all components | `project_path`?, `dry_run`? |
91
+
92
+ ### EasyEDA Community Library
93
+
94
+ | Tool | Description | Key Parameters |
95
+ |------|-------------|----------------|
96
+ | `easyeda_search` | Search community-contributed components | `query`, `source`, `open_preview` |
97
+ | `easyeda_get` | Get community component details | `uuid` |
98
+ | `easyeda_fetch` | Fetch community component to project | `uuid`, `project_path`, `include_3d` |
99
+ | `easyeda_get_3d_model` | Download community 3D model | `uuid`, `format` |
100
+
101
+ ## Usage Examples
102
+
103
+ ### Search for components
104
+
105
+ ```
106
+ component_search(query="STM32F103", in_stock=true, basic_only=true)
107
+ ```
108
+
109
+ Returns matching components with LCSC IDs, stock levels, and pricing.
110
+
111
+ ### Fetch to global library
112
+
113
+ ```
114
+ library_fetch(lcsc_id="C8734")
115
+ ```
116
+
117
+ Downloads the component and returns:
118
+ - `symbol_ref`: Reference for schematic (e.g., `JLC-MCP-ICs:STM32F103C8T6`)
119
+ - `footprint_ref`: Reference for PCB (e.g., `Package_QFP:LQFP-48_7x7mm_P0.5mm`)
120
+
121
+ ### Fetch to project-local library
122
+
123
+ ```
124
+ library_fetch(lcsc_id="C8734", project_path="/path/to/kicad/project", include_3d=true)
125
+ ```
126
+
127
+ ### Initialize libraries
128
+
129
+ ```
130
+ library_update()
131
+ ```
132
+
133
+ Creates the category-based library structure if it doesn't exist:
134
+ - Creates `JLC-MCP-Resistors.kicad_sym`, `JLC-MCP-Capacitors.kicad_sym`, etc.
135
+ - Creates `JLC-MCP.pretty/` footprint directory
136
+ - Creates `JLC-MCP.3dshapes/` 3D model directory
137
+
138
+ ### Search EasyEDA community
139
+
140
+ ```
141
+ easyeda_search(query="XIAO RP2040", open_preview=true)
142
+ ```
143
+
144
+ Opens an HTML preview in your browser with symbol/footprint thumbnails.
145
+
146
+ ## Library Organization
147
+
148
+ ### Category-Based Routing
149
+
150
+ Components are automatically sorted into category-specific libraries:
151
+
152
+ | Library | Components |
153
+ |---------|------------|
154
+ | `JLC-MCP-Resistors.kicad_sym` | Resistors, potentiometers |
155
+ | `JLC-MCP-Capacitors.kicad_sym` | Capacitors (ceramic, electrolytic, etc.) |
156
+ | `JLC-MCP-Inductors.kicad_sym` | Inductors, ferrite beads |
157
+ | `JLC-MCP-Diodes.kicad_sym` | Diodes, LEDs, Zeners |
158
+ | `JLC-MCP-Transistors.kicad_sym` | MOSFETs, BJTs |
159
+ | `JLC-MCP-ICs.kicad_sym` | Integrated circuits, MCUs |
160
+ | `JLC-MCP-Connectors.kicad_sym` | Connectors, headers |
161
+ | `JLC-MCP-Misc.kicad_sym` | Everything else |
162
+
163
+ ### Storage Paths
164
+
165
+ **Global (default):**
166
+
167
+ Libraries are stored in the KiCad 3rdparty folder for cross-platform portability:
168
+ - macOS/Windows: `~/Documents/KiCad/9.0/3rdparty/jlc_mcp/`
169
+ - Linux: `~/.local/share/kicad/9.0/3rdparty/jlc_mcp/`
170
+
171
+ Table entries use `${KICAD9_3RD_PARTY}` for portable paths.
172
+
173
+ ```
174
+ ~/Documents/KiCad/9.0/3rdparty/jlc_mcp/
175
+ ├── symbols/
176
+ │ ├── JLC-MCP-Resistors.kicad_sym
177
+ │ ├── JLC-MCP-Capacitors.kicad_sym
178
+ │ └── ...
179
+ ├── footprints/
180
+ │ └── JLC-MCP.pretty/
181
+ └── 3dmodels/
182
+ └── JLC-MCP.3dshapes/
183
+ ```
184
+
185
+ **Project-local (when `project_path` specified):**
186
+ ```
187
+ <project>/libraries/
188
+ ├── symbols/
189
+ │ └── JLC-MCP-*.kicad_sym
190
+ ├── footprints/
191
+ │ └── JLC-MCP.pretty/
192
+ └── 3dmodels/
193
+ └── JLC-MCP.3dshapes/
194
+ ```
195
+
196
+ ### Hybrid Footprint Strategy
197
+
198
+ - **Standard packages** (0603, 0805, SOIC-8, SOT-23, etc.) use KiCad's built-in footprints
199
+ - **Non-standard packages** get custom footprints generated in `JLC-MCP.pretty/`
200
+
201
+ This keeps libraries small while ensuring compatibility.
202
+
203
+ ## Integration with ai-eda
204
+
205
+ When used with the [ai-eda](https://github.com/anthropics/ai-eda) toolkit, the `/eda-source` command provides an interactive component sourcing workflow:
206
+
207
+ 1. Reads project constraints from `design-constraints.json`
208
+ 2. Searches local KiCad libraries first, then LCSC online
209
+ 3. Downloads and analyzes component datasheets
210
+ 4. Presents options with thermal and assembly validation
211
+ 5. Fetches selected components with proper references
212
+
213
+ Example:
214
+ ```
215
+ /eda-source main-mcu
216
+ ```
217
+
218
+ The command guides you through selecting an MCU that fits your project's requirements, validates it against design constraints, and adds it to your libraries.
219
+
220
+ ## Development
221
+
222
+ ```bash
223
+ bun run dev # Development with watch mode
224
+ bun run build # Build to ./dist
225
+ bun run start # Run the server
226
+ bun run typecheck # Type checking
227
+ bun run test # Run tests
228
+ bun run clean # Remove dist/
229
+ ```
230
+
231
+ ## How It Works
232
+
233
+ 1. **Search**: Queries JLCPCB's API for component data
234
+ 2. **Fetch**: Retrieves symbol/footprint data from EasyEDA (LCSC's component library backend)
235
+ 3. **Convert**: Transforms EasyEDA format to KiCad S-expression format
236
+ 4. **Route**: Categorizes components and routes to appropriate library files
237
+ 5. **Store**: Writes KiCad-compatible files and updates library tables
238
+
239
+ ## License
240
+
241
+ MIT
package/debug-text.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { easyedaCommunityClient } from './src/api/easyeda-community.ts';
2
+
3
+ async function debug() {
4
+ const uuid = 'c3c77f2e66fb4085aa0571e9b224d7d4';
5
+ const comp = await easyedaCommunityClient.getComponent(uuid);
6
+
7
+ // Check what tracks look like
8
+ console.log('=== TRACKS (first 3) ===');
9
+ for (const t of comp.footprint.tracks.slice(0, 3)) {
10
+ console.log(JSON.stringify(t, null, 2));
11
+ }
12
+
13
+ // Check arcs, circles, rects for silkscreen
14
+ console.log('\n=== ARCS ===');
15
+ console.log(comp.footprint.arcs.slice(0, 2));
16
+
17
+ console.log('\n=== CIRCLES ===');
18
+ console.log(comp.footprint.circles.slice(0, 2));
19
+
20
+ console.log('\n=== RECTS ===');
21
+ console.log(comp.footprint.rects.slice(0, 2));
22
+ }
23
+
24
+ debug().catch(console.error);