plm-upload-mcp 1.3.0 → 1.3.2

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 (3) hide show
  1. package/README.md +134 -134
  2. package/index.mjs +5 -18
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,134 +1,134 @@
1
- # plm-upload-mcp
2
-
3
- An MCP server for the **LionsBot PLM**. It **reads** the PLM — SKU folders, full
4
- component metadata, extracted drawing/BOM metadata, and product & staging BOMs — and
5
- **bulk-uploads** local files (SolidWorks STEP/PDF exports) into it, matched to a
6
- component by SKU, makes components' Drive folders and **uprevs** staging prototypes. It runs on **your own machine**, so it reads your exported files
7
- straight off disk, and it signs in as **you** with your PLM/hub login — every read is
8
- row-level-security scoped to you, and every uploaded file is tagged with who uploaded it.
9
-
10
- Pair it with your SolidWorks MCP: that MCP knows each part's SKU and exports the files;
11
- this MCP takes `{path, sku}` pairs and pushes them into the PLM.
12
-
13
- ## Setup
14
-
15
- Add one entry to your Claude MCP config (Claude Desktop: `claude_desktop_config.json`;
16
- Claude Code: `.mcp.json` or `claude mcp add`). Use **your own** PLM email + password:
17
-
18
- ```json
19
- {
20
- "mcpServers": {
21
- "plm-upload": {
22
- "command": "npx",
23
- "args": ["-y", "plm-upload-mcp@latest"],
24
- "env": {
25
- "PLM_EMAIL": "you@lionsbot.com",
26
- "PLM_PASSWORD": "your-plm-password"
27
- }
28
- }
29
- }
30
- }
31
- ```
32
-
33
- That's all. `npx -y plm-upload-mcp@latest` fetches and runs the latest version on every start; no clone, no build.
34
-
35
- > Your login is the same one you use for the Hardware Tools hub / PLM. Uploads are
36
- > attributed to you and require a `@lionsbot.com` account.
37
-
38
- ## Tools
39
-
40
- ### `upload_files`
41
- Uploads one or more files, each paired with its target SKU.
42
-
43
- - `files`: array of `{ path, sku, category? }`
44
- - `path` — absolute local path to the file
45
- - `sku` — component SKU, e.g. `MNT-1234-A0`; it must already exist in the PLM
46
- - `category` — optional PLM tag: `Default` | `Archive` | `Compliance` | `Ops`
47
-
48
- Each file lands in PLM storage and is mirrored into that SKU's Google Drive folder on
49
- the part's own drive (staging or main, from the component; created automatically if it
50
- doesn't exist). A SKU that isn't in the PLM is refused, so a typo never leaves a stray
51
- folder. Re-uploading a file with the **same name replaces it in place** — no duplicate
52
- pile-up on re-runs.
53
-
54
- A **PDF is then read** like an upload in the PLM's Files tab: a LionsBot drawing of that
55
- SKU fills the part's title-block fields (material, colour, drawing REV, manufacturing
56
- method). An injection moulded X revision then shows in **Injection Mold Staging**.
57
- Another company's PDF, or a drawing of another SKU, is uploaded but not read.
58
-
59
- Example ask: *"Upload C:\exports\bracket.step to SKU MNT-1234-A0 and C:\exports\bracket.pdf to the same SKU."*
60
-
61
- ### `create_folder`
62
- Finds or creates the `[SKU] Name` Drive folder of components already in the PLM, on each
63
- part's own drive, and links it to the component. Unknown SKUs are refused. Only needed
64
- for an empty folder: an upload makes the folder too.
65
-
66
- - `skus`: array of component SKUs
67
-
68
- ### `uprev_component`
69
- Uprevs a staging prototype to its next X revision (`MNT-1234-X1` → `MNT-1234-X2`), the
70
- same as **Uprev** in the PLM: a new component carrying the old one's details, with its
71
- own staging Drive folder; the old revision stays as history.
72
-
73
- - `sku`: the current staging SKU (X0–X8; releasing to A0 is a promotion request in the PLM)
74
- - `drawing_pdf`: optional path to the new revision's drawing PDF
75
- - `step`: optional path to the new revision's STEP model
76
- - `proceed_despite_warnings`: optional, see below
77
-
78
- The files are uploaded to the new revision, renamed to carry its SKU (an older revision's
79
- SKU in the name is swapped, else `[SKU] ` is put in front), and the drawing is read into
80
- the PLM. **The PDF is checked before anything is created**: if its title block still
81
- shows the old SKU, no SKU or REV, or another part, nothing is uprevved and the warnings come
82
- back. Claude shows them to you; say go ahead and it calls again with
83
- `proceed_despite_warnings: true`. The warnings are kept in the part's history.
84
-
85
- Example ask: *"Uprev MNT-1234-X1 with C:\exports\bracket.pdf and C:\exports\bracket.step."*
86
-
87
- ### `list_component_files`
88
- Lists the files currently in a component's Drive folder.
89
-
90
- - `sku`: component SKU
91
- - `bucket`: `main` (default) or `staging`
92
-
93
- ## Read-only tools
94
-
95
- All read tools query the PLM as **you** (RLS-scoped) — you only ever see what you're
96
- allowed to see. `bucket` / `classification` values are `main` (confirmed), `staging`
97
- (unconfirmed), or `all` (default).
98
-
99
- ### `list_sku_folders`
100
- Every component SKU with its Google Drive folder — the SKU→folder map (SKU, name,
101
- category, type, revision, status, staging flag, folder id/URL). Filters: `bucket`,
102
- `category`, `with_folder_only`, `limit`, `offset`.
103
-
104
- ### `get_component_metadata`
105
- Full component metadata (every column, incl. cost/supply, drawing-extracted fields,
106
- CAD provenance, compliance, and the `extract_meta` block). Pass a single `sku` for one
107
- part, or omit it to page through all. Filters: `search`, `bucket`, `category`,
108
- `status`, `limit`, `offset`.
109
-
110
- ### `list_bom_extract_metadata`
111
- The metadata machine-extracted from each part's drawing/BOM PDF (`extract_meta`): the
112
- Lionsbot-custom flag, SKU/drawing match check, per-field extracted values, and source
113
- file + who/when. Only extracted parts are returned. Filters: `sku`, `bucket`, `limit`,
114
- `offset`.
115
-
116
- ### `list_boms`
117
- BOMs across all products, each product carrying its BOM(s) + line items and a derived
118
- `staging` flag (a product is *staging* while its working BOM still contains any staging
119
- component). Working BOMs only by default. Filters: `product_sku`, `classification`,
120
- `include_snapshots`, `include_rows`, `max_rows_per_bom`.
121
-
122
- ## Config overrides (rarely needed)
123
-
124
- Baked to production defaults; override via env only if the PLM backend moves:
125
-
126
- | env | default |
127
- |---|---|
128
- | `PLM_GATEWAY` | `https://gateway-production-c13d.up.railway.app` |
129
- | `PLM_ANON_KEY` | (prod anon key) |
130
- | `PLM_EDGE_URL` | `https://plm-edge-production.up.railway.app` |
131
-
132
- ## Requirements
133
-
134
- Node.js 18+ (for built-in `fetch`).
1
+ # plm-upload-mcp
2
+
3
+ An MCP server for the **LionsBot PLM**. It **reads** the PLM — SKU folders, full
4
+ component metadata, extracted drawing/BOM metadata, and product & staging BOMs — and
5
+ **bulk-uploads** local files (SolidWorks STEP/PDF exports) into it, matched to a
6
+ component by SKU, makes components' Drive folders and **uprevs** staging prototypes. It runs on **your own machine**, so it reads your exported files
7
+ straight off disk, and it signs in as **you** with your PLM/hub login — every read is
8
+ row-level-security scoped to you, and every uploaded file is tagged with who uploaded it.
9
+
10
+ Pair it with your SolidWorks MCP: that MCP knows each part's SKU and exports the files;
11
+ this MCP takes `{path, sku}` pairs and pushes them into the PLM.
12
+
13
+ ## Setup
14
+
15
+ Add one entry to your Claude MCP config (Claude Desktop: `claude_desktop_config.json`;
16
+ Claude Code: `.mcp.json` or `claude mcp add`). Use **your own** PLM email + password:
17
+
18
+ ```json
19
+ {
20
+ "mcpServers": {
21
+ "plm-upload": {
22
+ "command": "npx",
23
+ "args": ["-y", "plm-upload-mcp@latest"],
24
+ "env": {
25
+ "PLM_EMAIL": "you@lionsbot.com",
26
+ "PLM_PASSWORD": "your-plm-password"
27
+ }
28
+ }
29
+ }
30
+ }
31
+ ```
32
+
33
+ That's all. `npx -y plm-upload-mcp@latest` fetches and runs the latest version on every start; no clone, no build.
34
+
35
+ > Your login is the same one you use for the Hardware Tools hub / PLM. Uploads are
36
+ > attributed to you and require a `@lionsbot.com` account.
37
+
38
+ ## Tools
39
+
40
+ ### `upload_files`
41
+ Uploads one or more files, each paired with its target SKU.
42
+
43
+ - `files`: array of `{ path, sku, category? }`
44
+ - `path` — absolute local path to the file
45
+ - `sku` — component SKU, e.g. `MNT-1234-A0`; it must already exist in the PLM
46
+ - `category` — optional PLM tag: `Default` | `Archive` | `Compliance` | `Ops`
47
+
48
+ Each file lands in PLM storage and is mirrored into that SKU's Google Drive folder on
49
+ the part's own drive (staging or main, from the component; created automatically if it
50
+ doesn't exist). A SKU that isn't in the PLM is refused, so a typo never leaves a stray
51
+ folder. Re-uploading a file with the **same name replaces it in place** — no duplicate
52
+ pile-up on re-runs.
53
+
54
+ A **PDF is then read** like an upload in the PLM's Files tab: a LionsBot drawing of that
55
+ SKU fills the part's title-block fields (material, colour, drawing REV, manufacturing
56
+ method). An injection moulded X revision then shows in **Injection Mold Staging**.
57
+ Another company's PDF, or a drawing of another SKU, is uploaded but not read.
58
+
59
+ Example ask: *"Upload C:\exports\bracket.step to SKU MNT-1234-A0 and C:\exports\bracket.pdf to the same SKU."*
60
+
61
+ ### `create_folder`
62
+ Finds or creates the `[SKU] Name` Drive folder of components already in the PLM, on each
63
+ part's own drive, and links it to the component. Unknown SKUs are refused. Only needed
64
+ for an empty folder: an upload makes the folder too.
65
+
66
+ - `skus`: array of component SKUs
67
+
68
+ ### `uprev_component`
69
+ Uprevs a staging prototype to its next X revision (`MNT-1234-X1` → `MNT-1234-X2`), the
70
+ same as **Uprev** in the PLM: a new component carrying the old one's details, with its
71
+ own staging Drive folder; the old revision stays as history.
72
+
73
+ - `sku`: the current staging SKU (X0–X8; releasing to A0 is a promotion request in the PLM)
74
+ - `drawing_pdf`: optional path to the new revision's drawing PDF
75
+ - `step`: optional path to the new revision's STEP model
76
+ - `proceed_despite_warnings`: optional, see below
77
+
78
+ The files are uploaded to the new revision, renamed to carry its SKU (an older revision's
79
+ SKU in the name is swapped, else `[SKU] ` is put in front), and the drawing is read into
80
+ the PLM. **The PDF is checked before anything is created**: if its title block still
81
+ shows the old SKU, no SKU or REV, or another part, nothing is uprevved and the warnings come
82
+ back. Claude shows them to you; say go ahead and it calls again with
83
+ `proceed_despite_warnings: true`. The warnings are kept in the part's history.
84
+
85
+ Example ask: *"Uprev MNT-1234-X1 with C:\exports\bracket.pdf and C:\exports\bracket.step."*
86
+
87
+ ### `list_component_files`
88
+ Lists the files currently in a component's Drive folder.
89
+
90
+ - `sku`: component SKU
91
+ - `bucket`: `main` (default) or `staging`
92
+
93
+ ## Read-only tools
94
+
95
+ All read tools query the PLM as **you** (RLS-scoped) — you only ever see what you're
96
+ allowed to see. `bucket` / `classification` values are `main` (confirmed), `staging`
97
+ (unconfirmed), or `all` (default).
98
+
99
+ ### `list_sku_folders`
100
+ Every component SKU with its Google Drive folder — the SKU→folder map (SKU, name,
101
+ category, type, revision, status, staging flag, folder id/URL). Filters: `bucket`,
102
+ `category`, `with_folder_only`, `limit`, `offset`.
103
+
104
+ ### `get_component_metadata`
105
+ Full component metadata (every column, incl. cost/supply, drawing-extracted fields,
106
+ CAD provenance, compliance, and the `extract_meta` block). Pass a single `sku` for one
107
+ part, or omit it to page through all. Filters: `search`, `bucket`, `category`,
108
+ `status`, `limit`, `offset`.
109
+
110
+ ### `list_bom_extract_metadata`
111
+ The metadata machine-extracted from each part's drawing/BOM PDF (`extract_meta`): the
112
+ Lionsbot-custom flag, SKU/drawing match check, per-field extracted values, and source
113
+ file + who/when. Only extracted parts are returned. Filters: `sku`, `bucket`, `limit`,
114
+ `offset`.
115
+
116
+ ### `list_boms`
117
+ BOMs across all products, each product carrying its BOM(s) + line items and a derived
118
+ `staging` flag (a product is *staging* while its working BOM still contains any staging
119
+ component). Working BOMs only by default. Filters: `product_sku`, `classification`,
120
+ `include_snapshots`, `include_rows`, `max_rows_per_bom`.
121
+
122
+ ## Config overrides (rarely needed)
123
+
124
+ Baked to production defaults; override via env only if the PLM backend moves:
125
+
126
+ | env | default |
127
+ |---|---|
128
+ | `PLM_GATEWAY` | `https://gateway-production-c13d.up.railway.app` |
129
+ | `PLM_ANON_KEY` | (prod anon key) |
130
+ | `PLM_EDGE_URL` | `https://plm-edge-production.up.railway.app` |
131
+
132
+ ## Requirements
133
+
134
+ Node.js 18+ (for built-in `fetch`).
package/index.mjs CHANGED
@@ -148,14 +148,6 @@ function nextRev(sku) {
148
148
  return { newSku: `${m[1]}-${m[2]}-X${Number(m[3]) + 1}` }
149
149
  }
150
150
 
151
- /** The file name carrying `sku`: an older revision's SKU in it is swapped,
152
- * else the SKU is put in front, so a STEP sent to a supplier names its part. */
153
- function nameWithSku(name, sku) {
154
- if (name.toUpperCase().includes(sku.toUpperCase())) return name
155
- const older = new RegExp(`${familyOf(sku).replace(/-/g, '\\-')}-(X\\d+|[A-Z]\\d)`, 'i')
156
- return older.test(name) ? name.replace(older, sku) : `[${sku}] ${name}`
157
- }
158
-
159
151
  /** Why a drawing PDF or STEP named `name` breaks the naming rule
160
152
  * `[SKU] Part Name REV0X` for `sku`; null when it follows it or is another
161
153
  * file type. A prompt only: the upload still goes ahead. */
@@ -284,7 +276,7 @@ const readLine = (read) => (read ? ` · ${read.text}${read.listed ? ' · now in
284
276
  const issueLine = (issue) => (issue ? `\n ⚠ ${issue} Tell the user.` : '')
285
277
 
286
278
  // --- Server ------------------------------------------------------------------
287
- const server = new McpServer({ name: 'plm-upload', version: '1.3.0' })
279
+ const server = new McpServer({ name: 'plm-upload', version: '1.3.2' })
288
280
 
289
281
  server.registerTool(
290
282
  'upload_files',
@@ -421,11 +413,11 @@ server.registerTool(
421
413
  "Uprevs a staging prototype part to its next X revision (MNT-1234-X1 -> MNT-1234-X2), the same as " +
422
414
  "Uprev in the PLM: a new component with the old one's details and its own staging Drive folder; " +
423
415
  "the old revision stays as history. Optionally uploads the new revision's drawing PDF and STEP in " +
424
- "the same step (renamed to carry the new SKU) and reads the drawing into the PLM, which lists an " +
416
+ "the same step (file names kept exactly as given, never renamed) and reads the drawing into the PLM, which lists an " +
425
417
  "injection moulded part in Injection Mold Staging. The PDF is checked BEFORE anything is created: " +
426
418
  "if its title block still shows the old SKU, no SKU/REV, or another part, NOTHING is uprevved and " +
427
419
  "the warnings come back. Show them to the user and only call again with " +
428
- "proceed_despite_warnings: true if they say to go ahead. A saved name that is not " +
420
+ "proceed_despite_warnings: true if they say to go ahead. A file name that is not " +
429
421
  "`[new SKU] Part Name REV0X` is uploaded but flagged (name_issue): tell the user. Only staging X0-X8 parts can be uprevved; " +
430
422
  "releasing to A0 is a promotion request in the PLM.",
431
423
  inputSchema: {
@@ -487,13 +479,11 @@ server.registerTool(
487
479
  try {
488
480
  for (const [path, kind] of [[drawing_pdf, 'DRAWING'], [step, 'STEP']]) {
489
481
  if (!path) continue
490
- const original = basename(path)
491
- const name = nameWithSku(original, created.new_sku)
492
- const up = await uploadOne({ path, sku: created.new_sku, skuName: c.name, bucket: 'staging', filename: name })
482
+ const name = basename(path)
483
+ const up = await uploadOne({ path, sku: created.new_sku, skuName: c.name, bucket: 'staging' })
493
484
  files.push({ ...up, name_issue: fileNameIssue(name, created.new_sku) })
494
485
  await audit(created.new_id, 'component.file_uploaded', {
495
486
  file: name,
496
- original_name: name !== original ? original : undefined,
497
487
  ...(kind === 'DRAWING' ? { drawing_sku: drawing?.sku ?? null, drawing_rev: drawing?.rev ?? null, warnings } : {}),
498
488
  })
499
489
  if (kind === 'DRAWING' && up.driveFileId) read = await readDrawing(created.new_id, created.new_sku, up.driveFileId, name)
@@ -765,9 +755,6 @@ if (process.argv.includes('--selftest')) {
765
755
  assert(JSON.stringify(stagingFilter('staging')) === '{"staging":"eq.true"}', 'staging -> staging=true')
766
756
  assert(JSON.stringify(stagingFilter('all')) === '{}', 'all -> no filter')
767
757
  // ported rules (same cases as the PLM's injectionMould.test.ts)
768
- assert(nameWithSku('Bracket.STEP', 'MNT-1234-X2') === '[MNT-1234-X2] Bracket.STEP', 'sku put in front')
769
- assert(nameWithSku('MNT-1234-X1 Bracket.pdf', 'MNT-1234-X2') === 'MNT-1234-X2 Bracket.pdf', 'older rev swapped')
770
- assert(nameWithSku('[MNT-1234-X2] Bracket.pdf', 'MNT-1234-X2') === '[MNT-1234-X2] Bracket.pdf', 'already named')
771
758
  assert(fileNameIssue('[SKN-0176-X1] DEPTH CAMERA COVER LEFT REV00.STEP', 'SKN-0176-X1') === null, 'named right')
772
759
  assert(fileNameIssue('notes.xlsx', 'SKN-0176-X1') === null, 'other file type not checked')
773
760
  assert(fileNameIssue('[SKN-0176-X1] DEPTH CAMERA COVER LEFT.pdf', 'SKN-0176-X1'), 'no REV flagged')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plm-upload-mcp",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "MCP server to read the LionsBot PLM (SKU folders, component metadata, extracted drawing metadata, product & staging BOMs) bulk-upload SolidWorks exports (STEP/PDF) into it by SKU, create components' Drive folders and uprev staging prototypes.",
5
5
  "license": "UNLICENSED",
6
6
  "keywords": ["mcp", "modelcontextprotocol", "lionsbot", "plm", "solidworks"],