plm-upload-mcp 1.5.0 → 1.5.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.
- package/index.mjs +22 -16
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -159,13 +159,15 @@ function nextRev(sku) {
|
|
|
159
159
|
return { newSku: `${m[1]}-${m[2]}-X${Number(m[3]) + 1}` }
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
/** Why a
|
|
163
|
-
* `[SKU] Part Name REV0X
|
|
164
|
-
*
|
|
165
|
-
function fileNameIssue(name, sku) {
|
|
166
|
-
const stem = /^(.*)\.(pdf|step|stp)$/i.exec(name)?.[1]
|
|
167
|
-
if (stem === undefined) return null
|
|
162
|
+
/** Why a file named `name` breaks the naming rule for `sku`; null when it follows it. A STEP, and a PDF that is a
|
|
163
|
+
* LionsBot drawing (`drawing`), is named `[SKU] Part Name REV0X`; any other file only starts with `[SKU] `.
|
|
164
|
+
* A prompt only: the upload still goes ahead. Copy of src/lib/injectionMould.ts fileNameIssue. */
|
|
165
|
+
function fileNameIssue(name, sku, drawing = false) {
|
|
168
166
|
const head = `[${sku}] `.toUpperCase()
|
|
167
|
+
if (!/\.(step|stp)$/i.test(name) && !(drawing && /\.pdf$/i.test(name))) {
|
|
168
|
+
return name.toUpperCase().startsWith(head) ? null : `${name} does not start with "[${sku}] ".`
|
|
169
|
+
}
|
|
170
|
+
const stem = name.replace(/\.[^.]+$/, '')
|
|
169
171
|
const ok = stem.toUpperCase().startsWith(head) && /^\S.* REV\d{2}$/i.test(stem.slice(head.length))
|
|
170
172
|
return ok ? null : `${name} is not named "[${sku}] Part Name REV0X".`
|
|
171
173
|
}
|
|
@@ -192,17 +194,19 @@ function drawingWarnings(read, newSku, prev) {
|
|
|
192
194
|
return out
|
|
193
195
|
}
|
|
194
196
|
|
|
195
|
-
/** What reading an uploaded drawing did; `listed` = it is now in Injection Mold Staging. */
|
|
197
|
+
/** What reading an uploaded drawing did; `listed` = it is now in Injection Mold Staging, `lionsbot` = a LionsBot title block. */
|
|
196
198
|
function readOutcome(res, sku) {
|
|
197
|
-
if (res.error) return { ok: false, text: res.error, listed: false }
|
|
199
|
+
if (res.error) return { ok: false, text: res.error, listed: false, lionsbot: false }
|
|
200
|
+
const lionsbot = res.extracted?.is_lionsbot === true
|
|
198
201
|
if (!res.written) {
|
|
199
202
|
const text = res.extracted?.is_lionsbot === false
|
|
200
203
|
? 'Not a LionsBot drawing, nothing read'
|
|
201
204
|
: `Drawing says ${res.sku_check?.drawing_sku ?? 'no SKU'}, not ${sku}: nothing read`
|
|
202
|
-
return { ok: false, text, listed: false }
|
|
205
|
+
return { ok: false, text, listed: false, lionsbot }
|
|
203
206
|
}
|
|
204
207
|
return {
|
|
205
208
|
ok: true,
|
|
209
|
+
lionsbot,
|
|
206
210
|
text: `Drawing read${res.extracted?.rev ? ` · REV ${res.extracted.rev}` : ''}`,
|
|
207
211
|
listed: IM_METHOD.test(res.extracted?.manufacturing_method ?? '') && isXRev(sku),
|
|
208
212
|
}
|
|
@@ -301,8 +305,9 @@ server.registerTool(
|
|
|
301
305
|
"the same name replaces it in place rather than duplicating. A PDF is then read like a PLM " +
|
|
302
306
|
"upload: a LionsBot drawing of that SKU fills the part's title-block fields (material, colour, " +
|
|
303
307
|
"drawing REV, method), which lists an injection moulded X revision in Injection Mold Staging. " +
|
|
304
|
-
"
|
|
305
|
-
"LEFT REV00.pdf`);
|
|
308
|
+
"STEP and LionsBot drawing PDF names should read `[SKU] Part Name REV0X` (e.g. `[SKN-0176-X1] DEPTH " +
|
|
309
|
+
"CAMERA COVER LEFT REV00.pdf`); any other file (datasheet, report…) only starts with `[SKU] `. One that " +
|
|
310
|
+
"doesn't is still uploaded but comes back with a name_issue: tell the user. " +
|
|
306
311
|
"You must supply the SKU for each file — the caller's own tooling (e.g. a SolidWorks MCP) " +
|
|
307
312
|
"already knows each part's SKU.",
|
|
308
313
|
inputSchema: {
|
|
@@ -333,7 +338,7 @@ server.registerTool(
|
|
|
333
338
|
if (!c) throw new Error('not in the PLM, nothing uploaded (create the component first)')
|
|
334
339
|
const up = await uploadOne({ path: f.path, sku: c.sku, skuName: c.name, category: f.category, bucket: driveOf(c) })
|
|
335
340
|
const read = isPdf(up.file) && up.driveFileId ? await readDrawing(c.id, c.sku, up.driveFileId, up.file) : undefined
|
|
336
|
-
results.push({ ok: true, ...up, read, name_issue: fileNameIssue(up.file, c.sku) })
|
|
341
|
+
results.push({ ok: true, ...up, read, name_issue: fileNameIssue(up.file, c.sku, !!read?.lionsbot) })
|
|
337
342
|
} catch (e) {
|
|
338
343
|
results.push({ ok: false, file: basename(f.path), sku, error: e instanceof Error ? e.message : String(e) })
|
|
339
344
|
}
|
|
@@ -497,7 +502,7 @@ server.registerTool(
|
|
|
497
502
|
path, sku: created.new_sku, skuName: c.name, bucket: 'staging', docType: kind,
|
|
498
503
|
audit: kind === 'DRAWING' ? { drawing_sku: drawing?.sku ?? null, drawing_rev: drawing?.rev ?? null, warnings } : undefined,
|
|
499
504
|
})
|
|
500
|
-
files.push({ ...up, name_issue: fileNameIssue(name, created.new_sku) })
|
|
505
|
+
files.push({ ...up, name_issue: fileNameIssue(name, created.new_sku, kind === 'DRAWING') })
|
|
501
506
|
if (kind === 'DRAWING' && up.driveFileId) read = await readDrawing(created.new_id, created.new_sku, up.driveFileId, name)
|
|
502
507
|
lines.push(`✓ ${name}${kind === 'DRAWING' ? readLine(read) : ''}${issueLine(files.at(-1).name_issue)}`)
|
|
503
508
|
}
|
|
@@ -799,9 +804,10 @@ if (process.argv.includes('--selftest')) {
|
|
|
799
804
|
assert(JSON.stringify(stagingFilter('all')) === '{}', 'all -> no filter')
|
|
800
805
|
// ported rules (same cases as the PLM's injectionMould.test.ts)
|
|
801
806
|
assert(fileNameIssue('[SKN-0176-X1] DEPTH CAMERA COVER LEFT REV00.STEP', 'SKN-0176-X1') === null, 'named right')
|
|
802
|
-
assert(fileNameIssue('
|
|
803
|
-
assert(fileNameIssue('
|
|
804
|
-
assert(fileNameIssue('[SKN-0176-
|
|
807
|
+
assert(fileNameIssue('[SKN-0176-X1] Datasheet 2420R.pdf', 'SKN-0176-X1') === null, 'other file: SKU in front is enough')
|
|
808
|
+
assert(fileNameIssue('notes.xlsx', 'SKN-0176-X1'), 'other file without the SKU flagged')
|
|
809
|
+
assert(fileNameIssue('[SKN-0176-X1] DEPTH CAMERA COVER LEFT.pdf', 'SKN-0176-X1', true), 'drawing without REV flagged')
|
|
810
|
+
assert(fileNameIssue('[SKN-0176-X0] DEPTH CAMERA COVER LEFT REV00.pdf', 'SKN-0176-X1', true), 'other rev flagged')
|
|
805
811
|
assert(nextRev('MNT-1234-X1').newSku === 'MNT-1234-X2', 'X1 -> X2')
|
|
806
812
|
assert(nextRev('MNT-1234-X9').newSku === 'MNT-1234-X10' && nextRev('MNT-1234-X98').newSku === 'MNT-1234-X99', 'X9 → X10, X98 → X99')
|
|
807
813
|
assert(nextRev('MNT-1234-X99').error && nextRev('MNT-1234-A0').error, 'X99 and A0 refused')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plm-upload-mcp",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
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"],
|