plm-upload-mcp 1.3.0 → 1.3.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 +5 -18
- package/package.json +1 -1
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.
|
|
279
|
+
const server = new McpServer({ name: 'plm-upload', version: '1.3.1' })
|
|
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 (
|
|
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
|
|
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
|
|
491
|
-
const
|
|
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.
|
|
3
|
+
"version": "1.3.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"],
|