mes-mcp 0.3.1 → 0.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.
@@ -15,7 +15,7 @@ export function registerMesPrompts(server) {
15
15
  text: [
16
16
  "你是 MES 业务助手,必须按当前账号权限和工具返回结果执行。",
17
17
  "不要猜测客户、物料、BOM、工艺路线、仓库等关键主数据;缺失时先查询或要求用户确认。",
18
- "动作目录有数百个动作。发现动作时用 mes_action.list,把你当前要做的事用一句自然语言意图传给 keyword(例如「销售单转生产计划」「采购入库」「报工」),它返回按相关性排序的 top-K 动作;再用 mes_action.detail 查看字段,最后用 mes_action.execute 执行。不要不带意图地翻页或猜路径,也不要依赖工具列表里必须存在 mes.<动作编码>。",
18
+ "动作目录有数百个动作。发现动作时用 mes_action.list,把你当前要做的事用一句自然语言意图传给 keyword(例如「销售单转生产计划」「采购入库」「报工」),它返回按相关性排序的 top-K 动作;再用 mes_action.detail 查看字段。遇到前置步骤、字段归属或业务口径不清楚时,先用 mes_manual.search 或 mes_workflow.detail 查后端手册索引,最后用 mes_action.execute 执行。不要不带意图地翻页或猜路径,也不要依赖工具列表里必须存在 mes.<动作编码>。",
19
19
  "mes_action.execute 返回的是执行信封,真实业务返回在 data 字段;confirm_required 产生的 invocationId 必须由同一公司/租户下有权限的账号审批。",
20
20
  "mes_api.read 只用于普通业务只读接口,pageSize 最大 100;如果返回 _mcpWarnings 或提示需要动态动作,请按提示调整。",
21
21
  "销售到出库的流程也走动态动作:先查客户和物料,再创建销售单、处理审批、确认销售单、转生产计划、排产或生成工单、报工、质检、生产入库/库存确认、发货出库。",
@@ -37,10 +37,11 @@ export function registerMesResources(server, client) {
37
37
  "## 工具使用顺序",
38
38
  "",
39
39
  "1. 使用 `mes_action.list` 或 `mes://agent/actions` 发现当前凭证和账号权限允许的动作。",
40
- "2. 使用 `mes_action.detail` 查看目标动作的路径、权限、DTO 名称和输入 schema",
41
- "3. 只读查询使用 `mes_api.read` 调用普通业务只读 POST 接口。",
42
- "4. 写入、确认、下达、报工、质检、出入库等动作使用 `mes_action.execute` 或可选的 `mes.<动作编码>`。",
43
- "5. `MES_REGISTER_DYNAMIC_TOOLS=false` 是默认推荐配置;此时工具列表只有 `mes_api.read`、`mes_action.list`、`mes_action.detail`、`mes_action.execute` 等基础工具。只有客户端必须直观看到 `mes.<动作编码>` 时才开启动态工具展开。",
40
+ "2. 使用 `mes_action.detail` 查看目标动作的路径、权限、DTO 名称、输入 schema、字段归属和推荐工作流提示。",
41
+ "3. 如果业务链路或字段归属不清楚,使用 `mes_manual.search` / `mes_manual.get` / `mes_workflow.detail` 查询后端提供的 AI 操作手册索引。",
42
+ "4. 只读查询使用 `mes_api.read` 调用普通业务只读 POST 接口。",
43
+ "5. 写入、确认、下达、报工、质检、出入库等动作使用 `mes_action.execute` 或可选的 `mes.<动作编码>`。",
44
+ "6. `MES_REGISTER_DYNAMIC_TOOLS=false` 是默认推荐配置;此时工具列表包含 `mes_api.read`、`mes_action.list/detail/execute`、`mes_manual.search/get`、`mes_workflow.detail` 等基础工具。只有客户端必须直观看到 `mes.<动作编码>` 时才开启动态工具展开。",
44
45
  "",
45
46
  "## 写入规则",
46
47
  "",
@@ -268,7 +268,7 @@ function registerGenericActionTools(server, client, searchService) {
268
268
  });
269
269
  server.registerTool("mes_action.detail", {
270
270
  title: "Get MES business action detail",
271
- description: "查询单个 MES 页面业务动作的路径、权限、DTO 名称和后端提供的输入 schema",
271
+ description: "查询单个 MES 页面业务动作的路径、权限、DTO 名称、输入 schema,以及后端提供的手册引用、字段归属和推荐工作流提示。",
272
272
  inputSchema: z.object({
273
273
  actionCode: z.string().min(1),
274
274
  }),
@@ -288,6 +288,100 @@ function registerGenericActionTools(server, client, searchService) {
288
288
  return formatToolResult(result);
289
289
  });
290
290
  });
291
+ server.registerTool("mes_manual.search", {
292
+ title: "Search MES operation manual",
293
+ description: "检索后端提供的 MES AI 操作手册索引,用于补充字段归属、前置动作、推荐流程和常见误用。适合在只看 action schema 不确定业务链路时调用。",
294
+ inputSchema: z
295
+ .object({
296
+ query: z.string().optional().describe("自然语言查询词"),
297
+ keyword: z.string().optional().describe("兼容字段:自然语言查询词"),
298
+ module: z.string().optional().describe("业务模块,如 schedule"),
299
+ actionCode: z
300
+ .string()
301
+ .optional()
302
+ .describe("相关动作编码,如 schedule.plan.auto"),
303
+ field: z
304
+ .string()
305
+ .optional()
306
+ .describe("字段名或字段归属,如 planStartDate"),
307
+ page: z.number().int().positive().optional(),
308
+ pageSize: z
309
+ .number()
310
+ .int()
311
+ .positive()
312
+ .max(MAX_MES_PAGE_SIZE)
313
+ .optional(),
314
+ })
315
+ .passthrough(),
316
+ annotations: {
317
+ readOnlyHint: true,
318
+ destructiveHint: false,
319
+ idempotentHint: true,
320
+ },
321
+ }, async (args) => {
322
+ return runTool({ toolName: "mes_manual.search" }, async () => {
323
+ const parsed = z
324
+ .object({
325
+ query: z.string().optional(),
326
+ keyword: z.string().optional(),
327
+ module: z.string().optional(),
328
+ actionCode: z.string().optional(),
329
+ field: z.string().optional(),
330
+ page: z.number().int().positive().optional(),
331
+ pageSize: z.number().int().positive().optional(),
332
+ })
333
+ .passthrough()
334
+ .parse(args ?? {});
335
+ const warnings = [];
336
+ const payload = normalizePageSize(parsed, warnings);
337
+ const result = await client.post("/integration/agent/manual/search", payload);
338
+ return formatToolResult(result, warnings);
339
+ });
340
+ });
341
+ server.registerTool("mes_manual.get", {
342
+ title: "Get MES operation manual section",
343
+ description: "按手册章节 ID 获取后端提供的 MES AI 操作手册详情,返回动作链、字段归属、步骤和常见误用。",
344
+ inputSchema: z.object({
345
+ id: z.string().min(1).describe("手册章节 ID"),
346
+ }),
347
+ annotations: {
348
+ readOnlyHint: true,
349
+ destructiveHint: false,
350
+ idempotentHint: true,
351
+ },
352
+ }, async (args) => {
353
+ return runTool({ toolName: "mes_manual.get" }, async () => {
354
+ const parsed = z
355
+ .object({
356
+ id: z.string().min(1),
357
+ })
358
+ .parse(args ?? {});
359
+ const result = await client.post("/integration/agent/manual/detail", parsed);
360
+ return formatToolResult(result);
361
+ });
362
+ });
363
+ server.registerTool("mes_workflow.detail", {
364
+ title: "Get MES recommended workflow",
365
+ description: "按工作流 ID 获取后端推荐的 MES 业务动作链。用于需要多个动作配合完成的场景,例如先更新生产计划开始日期,再从生产计划排产。",
366
+ inputSchema: z.object({
367
+ id: z.string().min(1).describe("业务工作流 ID"),
368
+ }),
369
+ annotations: {
370
+ readOnlyHint: true,
371
+ destructiveHint: false,
372
+ idempotentHint: true,
373
+ },
374
+ }, async (args) => {
375
+ return runTool({ toolName: "mes_workflow.detail" }, async () => {
376
+ const parsed = z
377
+ .object({
378
+ id: z.string().min(1),
379
+ })
380
+ .parse(args ?? {});
381
+ const result = await client.post("/integration/agent/workflows/detail", parsed);
382
+ return formatToolResult(result);
383
+ });
384
+ });
291
385
  server.registerTool("mes_action.execute", {
292
386
  title: "Execute MES business action",
293
387
  description: "执行一个由 mes_action.list 发现的 MES 页面业务动作。后端复用页面 Controller、DTO、权限、租户、状态机和调用日志。返回体是执行信封:真实业务结果在 data 字段;confirm_required 返回待确认 invocationId,必须由同一公司/租户下有权限的账号审批。",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mes-mcp",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "description": "MES MCP adapter for Marvis and AI agents",
6
6
  "license": "UNLICENSED",