pmclite-mcp 0.0.0-stage → 1.4.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/README.md CHANGED
@@ -1,3 +1,56 @@
1
- # Temporary Holding Version
1
+ # pmclite-mcp · 轻排生产排程 MCP 连接器
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 用自然语言驱动本机轻排系统(Windows 桌面版):查工单、验齐套、算工时、评交期、演排程、查延期原因、算采购缺口、报工。**生产数据不出厂** —— 所有计算都在本机完成。
4
+
5
+ ## 工作模式(自动选择)
6
+
7
+ | 模式 | 触发条件 | 行为 |
8
+ |---|---|---|
9
+ | 桌面版模式 | 本机找到 `MRP-PMC.exe` | 透传启动桌面版内置 MCP 服务,提供完整 21 个排产工具,直连本机数据库 |
10
+ | 演示模式 | 未找到桌面版 | 正常握手并返回同样的 21 个工具;工具调用由内置示例数据**真实执行**(解析参数、返回结构化数值),返回体统一标注 `mode=demo`,不会冒充真实客户数据 |
11
+
12
+ 查找 `MRP-PMC.exe` 的顺序:
13
+
14
+ 1. 环境变量 `PMCLITE_EXE` 指定的完整路径
15
+ 2. `%LOCALAPPDATA%\MRP-PMC\`(安装包默认位置)
16
+ 3. `%ProgramFiles%\MRP-PMC\`
17
+ 4. `%ProgramFiles(x86)%\MRP-PMC\`
18
+ 5. `%LOCALAPPDATA%\Programs\MRP-PMC\`
19
+
20
+ ## 安装使用
21
+
22
+ 一般不需要直接使用本包:在 WorkBuddy 等 MCP 客户端的连接器市场安装「轻排生产排程」即可,客户端会通过 `npx` 自动拉取。
23
+
24
+ 手动配置示例:
25
+
26
+ ```json
27
+ {
28
+ "mcpServers": {
29
+ "pmclite": {
30
+ "type": "stdio",
31
+ "command": "npx",
32
+ "args": ["-y", "pmclite-mcp@1.4.0"],
33
+ "timeout": 60000
34
+ }
35
+ }
36
+ }
37
+ ```
38
+
39
+ ## 演示模式说明
40
+
41
+ 未安装桌面版时,21 个工具用包内自带的虚构「示例工厂」数据真实运行:会解析你的参数、返回工单号、交期达成率、产线负荷、缺料缺口、BOM 展开等结构化结果,方便在审核环境 / 未购买前完整体验与评测工具能力。每条返回都带 `_meta.mode = "demo"` 和明确提示,**不是任何真实客户的数据**。要接入真实数据,安装桌面版并授权后重连即可,同一工具会自动切换为本机数据库。
42
+
43
+ ## 前置要求
44
+
45
+ - 真实数据模式:Windows 10 / 11(64 位)+ 轻排桌面版(从官网 https://www.pmclite.com 下载安装,30 天全功能试用,无需注册)
46
+ - 演示模式:任意可运行 Node 16+ 的平台(含 Linux / macOS 审核环境),无需桌面版
47
+
48
+ ## 安全说明
49
+
50
+ - 桌面版模式下所有工具调用都落在 **127.0.0.1 本机回环**,不经外网中转;
51
+ - 写操作(落库排程、报工、异常上报)在工具描述中标注「写操作」,调用前需用户确认;演示模式下写操作只返回模拟回执、不落库;
52
+ - 本包不携带任何账号凭据,授权信息只存在于本机桌面版内;演示数据为虚构示例,不来自任何客户。
53
+
54
+ ## 许可
55
+
56
+ © 广州轻排信息科技有限公司。仅供配合轻排桌面版使用。
package/demo-data.js ADDED
@@ -0,0 +1,203 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ * pmclite-mcp —— 演示模式内置数据集
4
+ *
5
+ * 用途:当本机未安装轻排桌面版(MRP-PMC.exe)时,连接器进入「演示模式」。
6
+ * 这份数据集是一间虚构的小型机械加工厂(示例工厂)的排产现状,日期相对
7
+ * 「今天」生成,保证任何时间运行都能得到自洽、可核对的结果。
8
+ *
9
+ * 所有工具返回都会明确标注 mode=demo,并提示「安装桌面版后返回本机真实数据」。
10
+ * 这里没有、也不会伪装成任何真实客户的数据。
11
+ */
12
+ 'use strict';
13
+
14
+ function pad(n) { return String(n).padStart(2, '0'); }
15
+ function fmt(d) { return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`; }
16
+ function dayOffset(n) {
17
+ const d = new Date();
18
+ d.setHours(0, 0, 0, 0);
19
+ d.setDate(d.getDate() + n);
20
+ return fmt(d);
21
+ }
22
+ function daysBetween(a, b) {
23
+ const da = new Date(a + 'T00:00:00');
24
+ const db = new Date(b + 'T00:00:00');
25
+ return Math.round((db - da) / 86400000);
26
+ }
27
+ const TODAY = dayOffset(0);
28
+
29
+ const LINES = ['一号线', '二号线', '三号线'];
30
+
31
+ const MATERIALS = [
32
+ { code: 'M001', name: '圆钢Φ20', spec: 'Φ20×3000', unit: 'kg', category: '钢材', price: 8.5, stock: 1200, safety: 300 },
33
+ { code: 'M002', name: '轴承6205', spec: '6205-2RS', unit: '个', category: '外购件', price: 12.0, stock: 85, safety: 100 },
34
+ { code: 'M003', name: '钢板Q235', spec: 't=8mm', unit: 'kg', category: '钢材', price: 5.2, stock: 600, safety: 200 },
35
+ { code: 'M004', name: '铝棒Φ30', spec: 'Φ30×2000', unit: 'kg', category: '铝材', price: 18.0, stock: 45, safety: 150 },
36
+ { code: 'M005', name: '密封圈', spec: 'ID25', unit: '个', category: '外购件', price: 1.5, stock: 300, safety: 100 },
37
+ { code: 'M006', name: '螺栓M8', spec: 'M8×25 8.8级', unit: '个', category: '标准件', price: 0.6, stock: 2000, safety: 500 },
38
+ { code: 'M007', name: '铜套', spec: 'Φ25×Φ18×20', unit: '个', category: '外购件', price: 6.8, stock: 40, safety: 80 },
39
+ ];
40
+
41
+ // 半成品:ST01 由铜套+圆钢加工而成,用于演示 BOM 多层展开
42
+ const SEMIS = [
43
+ {
44
+ code: 'ST01', name: '铜套坯', unit: '个', price: 22.0, stock: 30, safety: 40,
45
+ bom: [
46
+ { material: 'M007', qty: 1, lossRate: 0.02 },
47
+ { material: 'M001', qty: 0.3, lossRate: 0.01 },
48
+ ],
49
+ },
50
+ ];
51
+
52
+ const PRODUCTS = [
53
+ {
54
+ code: 'P001', name: '精密轴套', unit: '个', category: '成品', stock: 60, price: 165,
55
+ mode: 'batch', flowType: 'flow', setupMinutes: 12, postWaitMinutes: 0,
56
+ routing: [
57
+ { sequence: 10, name: '下料', workCenter: '一号线', minutes: 2, setupMinutes: 5, postWaitMinutes: 0 },
58
+ { sequence: 20, name: '车削', workCenter: '一号线', minutes: 8, setupMinutes: 12, postWaitMinutes: 0 },
59
+ { sequence: 30, name: '磨削', workCenter: '一号线', minutes: 5, setupMinutes: 8, postWaitMinutes: 0 },
60
+ ],
61
+ bom: [
62
+ { material: 'M001', qty: 2, lossRate: 0.02 },
63
+ { material: 'M002', qty: 1, lossRate: 0 },
64
+ { material: 'ST01', qty: 1, lossRate: 0, type: 'subproduct' },
65
+ ],
66
+ },
67
+ {
68
+ code: 'P002', name: '传动法兰', unit: '个', category: '成品', stock: 25, price: 128,
69
+ mode: 'batch', flowType: 'batch', setupMinutes: 15, postWaitMinutes: 0,
70
+ routing: [
71
+ { sequence: 10, name: '下料', workCenter: '二号线', minutes: 3, setupMinutes: 6, postWaitMinutes: 0 },
72
+ { sequence: 20, name: '钻孔', workCenter: '二号线', minutes: 6, setupMinutes: 10, postWaitMinutes: 0 },
73
+ { sequence: 30, name: '检验', workCenter: '二号线', minutes: 2, setupMinutes: 4, postWaitMinutes: 0 },
74
+ ],
75
+ bom: [
76
+ { material: 'M003', qty: 1.5, lossRate: 0.03 },
77
+ { material: 'M006', qty: 4, lossRate: 0.01 },
78
+ ],
79
+ },
80
+ {
81
+ code: 'P003', name: '连接座', unit: '个', category: '成品', stock: 18, price: 210,
82
+ mode: 'batch', flowType: 'flow', setupMinutes: 10, postWaitMinutes: 30,
83
+ routing: [
84
+ { sequence: 10, name: '铸造清理', workCenter: '一号线', minutes: 4, setupMinutes: 8, postWaitMinutes: 0 },
85
+ { sequence: 20, name: '铣削', workCenter: '一号线', minutes: 9, setupMinutes: 12, postWaitMinutes: 30 },
86
+ { sequence: 30, name: '装配', workCenter: '一号线', minutes: 3, setupMinutes: 6, postWaitMinutes: 0 },
87
+ ],
88
+ bom: [
89
+ { material: 'M004', qty: 1.2, lossRate: 0.05 },
90
+ { material: 'M005', qty: 2, lossRate: 0 },
91
+ { material: 'M006', qty: 3, lossRate: 0.01 },
92
+ ],
93
+ },
94
+ {
95
+ code: 'P004', name: '端盖', unit: '个', category: '成品', stock: 42, price: 96,
96
+ mode: 'batch', flowType: 'batch', setupMinutes: 8, postWaitMinutes: 0,
97
+ routing: [
98
+ { sequence: 10, name: '车削', workCenter: '三号线', minutes: 5, setupMinutes: 8, postWaitMinutes: 0 },
99
+ { sequence: 20, name: '钻孔', workCenter: '三号线', minutes: 4, setupMinutes: 6, postWaitMinutes: 0 },
100
+ ],
101
+ bom: [
102
+ { material: 'M004', qty: 0.8, lossRate: 0.04 },
103
+ { material: 'M006', qty: 4, lossRate: 0.01 },
104
+ ],
105
+ },
106
+ ];
107
+
108
+ const SALES_ORDERS = [
109
+ { code: 'SO-1001', customer: '华兴机械', product: 'P001', qty: 500, dueDate: dayOffset(2), status: '生产中' },
110
+ { code: 'SO-1002', customer: '远东传动', product: 'P002', qty: 300, dueDate: dayOffset(5), status: '待生产' },
111
+ { code: 'SO-1003', customer: '华兴机械', product: 'P003', qty: 200, dueDate: dayOffset(-1), status: '生产中' },
112
+ { code: 'SO-1004', customer: '南方精工', product: 'P004', qty: 600, dueDate: dayOffset(8), status: '待生产' },
113
+ ];
114
+
115
+ // 工单:状态、产线、优先级、计划日期、交期、数量、已报数量都刻意做成自洽
116
+ const WORK_ORDERS = [
117
+ { code: 'WO-0028', product: 'P001', qty: 500, actualQty: 320, status: '进行中', priority: '高', line: '一号线', planStart: dayOffset(-2), planEnd: dayOffset(1), dueDate: dayOffset(2), salesOrder: 'SO-1001' },
118
+ { code: 'WO-0027', product: 'P002', qty: 300, actualQty: 0, status: '待排产', priority: '中', line: null, planStart: null, planEnd: null, dueDate: dayOffset(5), salesOrder: 'SO-1002' },
119
+ { code: 'WO-0026', product: 'P003', qty: 200, actualQty: 80, status: '进行中', priority: '高', line: '一号线', planStart: dayOffset(-3), planEnd: dayOffset(-1), dueDate: dayOffset(-1), salesOrder: 'SO-1003' },
120
+ { code: 'WO-0025', product: 'P001', qty: 400, actualQty: 400, status: '已完成', priority: '中', line: '三号线', planStart: dayOffset(-8), planEnd: dayOffset(-4), dueDate: dayOffset(-3), finishedAt: dayOffset(-4), salesOrder: 'SO-1001' },
121
+ { code: 'WO-0024', product: 'P004', qty: 600, actualQty: 0, status: '待排产', priority: '低', line: null, planStart: null, planEnd: null, dueDate: dayOffset(8), salesOrder: 'SO-1004' },
122
+ { code: 'WO-0023', product: 'P002', qty: 150, actualQty: 150, status: '已完成', priority: '中', line: '二号线', planStart: dayOffset(-10), planEnd: dayOffset(-6), dueDate: dayOffset(-7), finishedAt: dayOffset(-6), salesOrder: 'SO-1002' },
123
+ { code: 'WO-0022', product: 'P003', qty: 250, actualQty: 0, status: '待排产', priority: '高', line: '一号线', planStart: dayOffset(-1), planEnd: null, dueDate: dayOffset(3), salesOrder: 'SO-1003' },
124
+ { code: 'WO-0021', product: 'P004', qty: 300, actualQty: 120, status: '进行中', priority: '中', line: '三号线', planStart: dayOffset(-1), planEnd: dayOffset(2), dueDate: dayOffset(4), salesOrder: 'SO-1004' },
125
+ { code: 'WO-0020', product: 'P001', qty: 200, actualQty: 200, status: '已完成', priority: '低', line: '二号线', planStart: dayOffset(-15), planEnd: dayOffset(-11), dueDate: dayOffset(-10), finishedAt: dayOffset(-11), salesOrder: 'SO-1001' },
126
+ { code: 'WO-0019', product: 'P002', qty: 180, actualQty: 0, status: '已取消', priority: '低', line: '二号线', planStart: dayOffset(-1), planEnd: dayOffset(1), dueDate: dayOffset(1), salesOrder: 'SO-1002' },
127
+ { code: 'WO-0018', product: 'P003', qty: 120, actualQty: 0, status: '待排产', priority: '中', line: null, planStart: null, planEnd: null, dueDate: dayOffset(6), salesOrder: 'SO-1003' },
128
+ { code: 'WO-0017', product: 'P004', qty: 220, actualQty: 220, status: '已完成', priority: '中', line: '一号线', planStart: dayOffset(-20), planEnd: dayOffset(-16), dueDate: dayOffset(-16), finishedAt: dayOffset(-16), salesOrder: 'SO-1004' },
129
+ ];
130
+
131
+ // 工序级进度:仅进行中/已完成工单有报工
132
+ const PROCESS_PROGRESS = {
133
+ 'WO-0028': [{ sequence: 10, planQty: 500, actualQty: 500 }, { sequence: 20, planQty: 500, actualQty: 320 }, { sequence: 30, planQty: 500, actualQty: 0 }],
134
+ 'WO-0026': [{ sequence: 10, planQty: 200, actualQty: 200 }, { sequence: 20, planQty: 200, actualQty: 80 }, { sequence: 30, planQty: 200, actualQty: 0 }],
135
+ 'WO-0021': [{ sequence: 10, planQty: 300, actualQty: 300 }, { sequence: 20, planQty: 300, actualQty: 120 }],
136
+ 'WO-0025': [{ sequence: 10, planQty: 400, actualQty: 400 }, { sequence: 20, planQty: 400, actualQty: 400 }, { sequence: 30, planQty: 400, actualQty: 400 }],
137
+ 'WO-0023': [{ sequence: 10, planQty: 150, actualQty: 150 }, { sequence: 20, planQty: 150, actualQty: 150 }, { sequence: 30, planQty: 150, actualQty: 150 }],
138
+ 'WO-0020': [{ sequence: 10, planQty: 200, actualQty: 200 }, { sequence: 20, planQty: 200, actualQty: 200 }, { sequence: 30, planQty: 200, actualQty: 200 }],
139
+ 'WO-0017': [{ sequence: 10, planQty: 220, actualQty: 220 }, { sequence: 20, planQty: 220, actualQty: 220 }],
140
+ };
141
+
142
+ const PURCHASE_ORDERS = [
143
+ { code: 'PO-2001', material: 'M002', qty: 200, receivedQty: 0, eta: dayOffset(3), supplier: '轴承通达' },
144
+ { code: 'PO-2002', material: 'M004', qty: 100, receivedQty: 0, eta: dayOffset(5), supplier: '华南铝业' },
145
+ { code: 'PO-2003', material: 'M007', qty: 80, receivedQty: 40, eta: dayOffset(2), supplier: '精密铜业' },
146
+ ];
147
+
148
+ // 报工流水:带标准工时与实际工时,供工时偏差计算
149
+ const REPORT_RECORDS = [
150
+ { date: dayOffset(0), work_order: 'WO-0028', sequence: 20, qty: 60, hours: 9.6, standardHours: 8.0, reporter: '张师傅', unit: '个' },
151
+ { date: dayOffset(0), work_order: 'WO-0021', sequence: 20, qty: 40, hours: 3.4, standardHours: 2.7, reporter: '李师傅', unit: '个' },
152
+ { date: dayOffset(0), work_order: 'WO-0026', sequence: 20, qty: 20, hours: 3.3, standardHours: 3.0, reporter: '王师傅', unit: '个' },
153
+ { date: dayOffset(-1), work_order: 'WO-0028', sequence: 20, qty: 80, hours: 12.0, standardHours: 10.7, reporter: '张师傅', unit: '个' },
154
+ { date: dayOffset(-1), work_order: 'WO-0025', sequence: 30, qty: 100, hours: 8.8, standardHours: 8.3, reporter: '陈师傅', unit: '个' },
155
+ { date: dayOffset(-2), work_order: 'WO-0026', sequence: 20, qty: 60, hours: 10.2, standardHours: 9.0, reporter: '王师傅', unit: '个' },
156
+ { date: dayOffset(-2), work_order: 'WO-0021', sequence: 20, qty: 50, hours: 4.1, standardHours: 3.3, reporter: '李师傅', unit: '个' },
157
+ { date: dayOffset(-3), work_order: 'WO-0025', sequence: 20, qty: 150, hours: 34.0, standardHours: 30.0, reporter: '陈师傅', unit: '个' },
158
+ { date: dayOffset(-3), work_order: 'WO-0023', sequence: 20, qty: 70, hours: 7.5, standardHours: 7.0, reporter: '赵师傅', unit: '个' },
159
+ { date: dayOffset(-4), work_order: 'WO-0028', sequence: 10, qty: 100, hours: 4.6, standardHours: 3.3, reporter: '张师傅', unit: '个' },
160
+ { date: dayOffset(-5), work_order: 'WO-0020', sequence: 30, qty: 100, hours: 9.0, standardHours: 8.3, reporter: '刘师傅', unit: '个' },
161
+ ];
162
+
163
+ const INCIDENTS = [
164
+ { date: dayOffset(0), work_order: 'WO-0028', type: 'shortage', minutes: 45, description: '轴承6205 库存不足,等待采购到货', reported_by: '张师傅' },
165
+ { date: dayOffset(0), work_order: 'WO-0026', type: 'quality', minutes: 30, description: '磨削尺寸超差,需返工 20 件', reported_by: '王师傅' },
166
+ { date: dayOffset(-1), work_order: 'WO-0021', type: 'breakdown', minutes: 60, description: '三号线空压机压力不足,停机检修', reported_by: '李师傅' },
167
+ { date: dayOffset(-2), work_order: 'WO-0026', type: 'shortage', minutes: 90, description: '铝棒Φ30 缺料,影响连接座生产', reported_by: '王师傅' },
168
+ { date: dayOffset(-3), work_order: 'WO-0023', type: 'quality', minutes: 25, description: '法兰孔位毛刺,返修', reported_by: '赵师傅' },
169
+ ];
170
+
171
+ // 出勤记录(演示「人力出勤」口径;本系统桌面版暂无独立考勤模块,演示模式提供示例数据)
172
+ const ATTENDANCE_RECORDS = [
173
+ { date: dayOffset(0), line: '一号线', shift: '白班', headcount: 8, hours: 8, overtimeHours: 1.5 },
174
+ { date: dayOffset(0), line: '二号线', shift: '白班', headcount: 6, hours: 8, overtimeHours: 0 },
175
+ { date: dayOffset(0), line: '三号线', shift: '白班', headcount: 5, hours: 8, overtimeHours: 0.5 },
176
+ { date: dayOffset(-1), line: '一号线', shift: '白班', headcount: 8, hours: 8, overtimeHours: 1.0 },
177
+ { date: dayOffset(-1), line: '二号线', shift: '白班', headcount: 6, hours: 8, overtimeHours: 0 },
178
+ { date: dayOffset(-1), line: '三号线', shift: '夜班', headcount: 4, hours: 8, overtimeHours: 2.0 },
179
+ { date: dayOffset(-2), line: '一号线', shift: '白班', headcount: 7, hours: 8, overtimeHours: 0 },
180
+ ];
181
+
182
+ const IMPORT_SCHEMA = {
183
+ tables: [
184
+ { name: 'materials', label: '物料', fields: [{ name: 'code', type: 'string', required: false }, { name: 'name', type: 'string', required: true }, { name: 'spec', type: 'string' }, { name: 'unit', type: 'string' }, { name: 'price', type: 'number' }, { name: 'category', type: 'string' }] },
185
+ { name: 'products', label: '产品', fields: [{ name: 'code', type: 'string', required: false }, { name: 'name', type: 'string', required: true }, { name: 'flowType', type: 'string', enum: ['flow', 'batch'] }, { name: 'processMinutes', type: 'number' }, { name: 'mode', type: 'string' }] },
186
+ { name: 'bomItems', label: 'BOM / 工艺路线', fields: [{ name: 'productCode', type: 'string', required: true }, { name: 'material', type: 'string', required: true }, { name: 'qty', type: 'number', required: true }, { name: 'lossRate', type: 'number' }, { name: 'type', type: 'string', enum: ['material', 'process', 'subproduct'] }, { name: 'sequence', type: 'integer' }] },
187
+ { name: 'workOrders', label: '工单', fields: [{ name: 'code', type: 'string', required: false }, { name: 'product', type: 'string', required: true }, { name: 'qty', type: 'number', required: true }, { name: 'priority', type: 'string', enum: ['高', '中', '低'] }, { name: 'dueDate', type: 'string' }] },
188
+ { name: 'inventory', label: '库存', fields: [{ name: 'material', type: 'string', required: true }, { name: 'quantity', type: 'number', required: true }] },
189
+ { name: 'lineConfig', label: '产线配置', fields: [{ name: 'name', type: 'string', required: true }, { name: 'hoursPerDay', type: 'number' }, { name: 'parallel', type: 'integer' }] },
190
+ ],
191
+ order: ['materials', 'products', 'lineConfig', 'bomItems', 'workOrders', 'inventory'],
192
+ codeRules: {
193
+ materials: '未给 code 时按 name+spec 匹配现有物料,匹配不到自动生成 AUTO-MAT-XXXXX',
194
+ products: '未给 code 时按 name 匹配现有产品,匹配不到自动生成 AUTO-PROD-XXXXX',
195
+ workOrders: '未给 code 时自动生成 WO-XXXXX',
196
+ },
197
+ };
198
+
199
+ module.exports = {
200
+ TODAY, LINES, MATERIALS, SEMIS, PRODUCTS, SALES_ORDERS, WORK_ORDERS,
201
+ PROCESS_PROGRESS, PURCHASE_ORDERS, REPORT_RECORDS, INCIDENTS,
202
+ ATTENDANCE_RECORDS, IMPORT_SCHEMA, dayOffset, daysBetween,
203
+ };