@carbonstopper/agent-mcp 0.1.48 → 0.1.50

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.
@@ -1,6 +1,6 @@
1
1
  # CBAM Agent 服务端接入文档
2
2
 
3
- > 文档版本:1.0
3
+ > 文档版本:1.2
4
4
  > 更新时间:2026-08-12
5
5
  > 适用项目:`carbonstop-ai`、`carbonstop-agent-mcp`、`carbonstop-cbam2`
6
6
  > 面向人员:Agent 服务端、会话编排服务及服务端联调同事
@@ -9,7 +9,7 @@
9
9
 
10
10
  CBAM 已按“一个会话可以创建和操作多份 CBAM 报告”的方式接入 Agent。Agent 通过 `carbonstop-agent-mcp` 调用 CBAM 服务端能力,不直接调用原页面接口,也不在 Agent 侧复刻计算或文件生成逻辑。
11
11
 
12
- 当前提供 16 个面向任务的 MCP 工具,内部映射到 CBAM 的 31 个原子接口,覆盖:
12
+ 当前提供 15 个面向任务的 MCP 工具,内部映射到 CBAM 的 31 个原子接口,覆盖:
13
13
 
14
14
  - 基础数据查询、组织树、工厂查询;
15
15
  - 报告检索、创建、修改、流程快照和分区详情;
@@ -23,15 +23,15 @@ CBAM 已按“一个会话可以创建和操作多份 CBAM 报告”的方式接
23
23
  - Agent 负责理解用户意图、收集字段、选择报告、调用工具和解释结果。
24
24
  - MCP 负责参数约束、工具合并、鉴权头转发和后端路由。
25
25
  - CBAM 服务负责权限校验、业务校验、计算、数据库事务、文件生成和下载记录。
26
- - Agent 服务只需输出约定的确认状态、`bizRef` 和业务卡片数据;前端页面实现不属于本文接入范围。
27
- - 认证审批不是当前 CBAM Agent 主流程,不需要 Agent 模拟审批;报告业务数据仍保留在 CBAM 服务中。
26
+ - Agent 服务复用现有操作确认状态,并输出 `bizRef` 和业务卡片数据;前端页面实现不属于本文接入范围。
27
+ - CBAM 认证审核不是当前 Agent 主流程,不需要模拟认证审核;它与删除、生成等操作确认不是同一概念。
28
28
 
29
29
  ## 2. 总体调用链
30
30
 
31
31
  ```text
32
32
  用户
33
33
  -> Carbon Agent 会话服务(意图识别、上下文、确认交互)
34
- -> carbonstop-agent-mcp(16 个 cbam_* 工具)
34
+ -> carbonstop-agent-mcp(15 个 cbam_* 工具)
35
35
  -> 碳云网关 /cbam2/**
36
36
  -> carbonstop-cbam2 /agent/internal/skills/cbam/**
37
37
  -> CBAM 数据库、计算逻辑、文件服务、下载管理
@@ -45,10 +45,10 @@ Agent 服务端接入时需要完成以下七件事:
45
45
 
46
46
  1. 在每轮开始时恢复 `sessionId` 对应的 CBAM 报告列表,并解析明确的 `bizRef`。
47
47
  2. 将本次用户意图路由到 CBAM 场景,只向模型暴露本任务需要的 MCP 工具。
48
- 3. 在调用写工具前补充稳定的 `idempotencyKey`,并保存工具调用与消息/任务的关联。
49
- 4. 识别 `WAIT_CONFIRM`,持久化 `pendingActionId` 和原业务参数,中断本轮等待用户确认。
50
- 5. 用户确认后恢复原动作;拒绝后结束动作,不调用第二阶段接口。
51
- 6. 对碳税和报告生成维护异步任务状态,轮询到终态或交给已有任务调度器继续执行。
48
+ 3. 不向模型暴露 `idempotencyKey`、`confirmed` 等技术字段;由 Wrapper 在调用写工具前补充稳定的 `idempotencyKey`。
49
+ 4. 在远程调用 MCP 之前识别高风险动作,复用现有 Aegra/LangGraph 审批 `interrupt` 等待用户确认。
50
+ 5. 用户确认后由 Wrapper 注入 `confirmed=true` 并单次调用 MCP;拒绝时不调用 MCP。
51
+ 6. 对碳税任务继续按现有方式维护异步状态;报告生成只调用 `cbam_report_generate`,由 MCP 内部等待生成终态。
52
52
  7. 把明确的报告对象写回会话业务引用,并向消息流输出 `cbam2_report` 卡片。
53
53
 
54
54
  Agent 服务发给模型/编排器的上下文可继续沿用现有字段:
@@ -82,11 +82,15 @@ Agent 服务发给模型/编排器的上下文可继续沿用现有字段:
82
82
  -> 解析唯一 reportId;多份且不明确则 NEED_USER_INPUT
83
83
  -> 调用读工具取得当前真实状态
84
84
  -> 缺字段则 NEED_USER_INPUT
85
- -> 调用写工具
85
+ -> 普通写工具:Wrapper 注入 idempotencyKey 后调用 MCP
86
+ -> 高风险写工具:先执行已有 LangGraph 审批 interrupt
87
+ -> 拒绝:结束动作,不调用 MCP
88
+ -> 批准:Wrapper 注入 idempotencyKey + confirmed=true,单次调用 MCP
89
+ -> 处理工具结果
86
90
  -> SUCCESS:保存业务引用、刷新快照、输出文本/卡片
87
- -> WAIT_CONFIRM:保存 pendingAction + 原参数,返回 WAIT_CONFIRM
88
91
  -> FAILED:按结构化 error 修正或返回可解释错误
89
- -> 异步动作:登记 task/generationId 并轮询或后台续跑
92
+ -> 碳税异步动作:登记 taskId 并轮询或后台续跑
93
+ -> 报告生成:接收 MCP 返回的 COMPLETED/FAILED;极端超时时用同一幂等键重调生成工具继续等待
90
94
  ```
91
95
 
92
96
  必须遵守以下原则:
@@ -95,7 +99,7 @@ Agent 服务发给模型/编排器的上下文可继续沿用现有字段:
95
99
  2. 所有组织、工厂、字典、类别、CN、默认工艺等值必须先查工具,不能由模型编造 ID 或编码。
96
100
  3. 更新完整表单前先读取现值,保留用户未要求修改的字段。
97
101
  4. 同一会话出现多份报告且用户未明确指定时,必须让用户选择,不能默认取第一份。
98
- 5. 删除、工厂写入、碳税计算和报告生成必须执行两阶段确认。
102
+ 5. 删除、工厂写入、碳税计算和报告生成必须先走现有 Agent 审批,批准后只调用一次 MCP。
99
103
  6. 报告文件只能由 CBAM 服务生成;生成成功后自动进入碳云“下载管理”,模块为 `cbam2`。
100
104
 
101
105
  ## 3. 服务配置
@@ -299,12 +303,12 @@ Agent 服务端只负责产出上述卡片数据,并在后续消息中消费
299
303
  7. 用户补充某个区块时,先读该区块,再用对应写工具保存。
300
304
  8. 碳税计算返回任务后,轮询 `view=carbon_tax_status`。
301
305
  9. 生成前调用 `view=readiness`;说明阻断项和非阻断提示。
302
- 10. 用户确认后调用 `cbam_report_generate`,再轮询 `cbam_report_generation_status`。
306
+ 10. 用户确认后调用一次 `cbam_report_generate`;MCP 内部完成生成状态轮询。
303
307
  11. 完成后展示后端返回的文件地址,并提示已进入碳云下载管理。
304
308
 
305
309
  重要说明:报告的一般信息创建完成后,就具备“请求生成”的基本条件。后续区块属于逐步补充数据;缺少可选数据会形成 `warnings` 或导致报告内容不完整,但不能由 Agent 自行把所有缺项都当成阻断。是否可生成只认 `readiness.canGenerate`/`valid` 和 `blockers`。
306
310
 
307
- ## 6. 16 个 MCP 工具总表
311
+ ## 6. 15 个 MCP 工具总表
308
312
 
309
313
  | MCP 工具 | action/view | 用途 | 内部接口数量 |
310
314
  | --- | --- | --- | ---: |
@@ -322,8 +326,7 @@ Agent 服务端只负责产出上述卡片数据,并在后续消息中消费
322
326
  | `cbam_sale_product_manage` | `save/delete` | 外售产品批量保存、删除 | 2 |
323
327
  | `cbam_carbon_tax_manage` | `save/delete/calculate` | 碳税数据保存、删除、异步计算 | 3 |
324
328
  | `cbam_data_quality_update` | - | 更新数据质量完整表单 | 1 |
325
- | `cbam_report_generate` | - | 异步生成服务端报告文件 | 1 |
326
- | `cbam_report_generation_status` | - | 查询报告生成状态 | 1 |
329
+ | `cbam_report_generate` | - | 启动服务端异步生成并由 MCP 内部等待最终文件 | 2 |
327
330
  | **合计** | | | **31** |
328
331
 
329
332
  ## 7. 公共入参与返回协议
@@ -341,13 +344,12 @@ Agent 服务端只负责产出上述卡片数据,并在后续消息中消费
341
344
  | `eventId` | 否 | Agent 事件 ID |
342
345
  | `lang` | 否 | `zh` 或 `en`,默认 `zh`;字典和描述按该语言返回 |
343
346
 
344
- 写工具在上述字段之外必须带:
347
+ 以下技术字段由 Agent Wrapper 补充,不进入模型可见的工具参数:
345
348
 
346
349
  | 字段 | 必填 | 说明 |
347
350
  | --- | --- | --- |
348
- | `idempotencyKey` | 是 | 本次业务动作唯一键,最长 128 个字符 |
349
- | `confirmed` | 仅高风险工具确认第二阶段必填 | 用户已确认时传 `true`;普通写工具不暴露该字段 |
350
- | `pendingActionId` | 仅高风险工具确认第二阶段必填 | 第一阶段返回的确认动作 ID;普通写工具不暴露该字段 |
351
+ | `idempotencyKey` | 所有写工具必填 | 本次业务动作唯一键,最长 128 个字符;LangGraph 恢复或同一动作重试时复用 |
352
+ | `confirmed` | 仅高风险动作必填 | 复用现有审批流程;用户批准后由可信 Wrapper 注入 `true` |
351
353
 
352
354
  所有 Long 类型 ID 可传整数或纯数字字符串。不要传浮点数、名称或模型生成的临时 ID。
353
355
 
@@ -372,17 +374,17 @@ CBAM 内部接口使用“HTTP 外层 + CBAM 业务内层”:
372
374
  Agent 判断结果时必须查看业务内层 `data.status`,不能只看 HTTP 200 或外层 `code=200`:
373
375
 
374
376
  - `SUCCESS`:业务执行成功;使用内层 `data.data`。
375
- - `WAIT_CONFIRM`:尚未执行,展示确认;读取 `data.data.pendingActionId`。
376
377
  - `FAILED`:未执行或回滚;读取 `data.error`。
377
378
 
378
- MCP 会把真正的 `FAILED` 包装成 MCP error result,并把原始后端结构保留在返回对象的 `raw` 字段。`WAIT_CONFIRM` 是已成功分发但等待确认的控制状态,MCP 会将它作为正常工具结果返回,不设置 `isError=true`:
379
+ MCP 会把 `FAILED` 包装成 MCP error result,并把原始后端结构保留在返回对象的 `raw` 字段:
379
380
 
380
381
  ```text
381
- MCP 正常结果文本 JSON:response.data.status / response.data.data.pendingActionId
382
+ MCP 正常结果文本 JSON:response.data.status / response.data.data
382
383
  真正失败的 MCP 错误:response.raw.data.status / response.raw.data.error
383
384
  ```
384
385
 
385
- 禁止把 `WAIT_CONFIRM` 当成真正执行失败,也禁止在未获得用户确认时自动发起第二次调用。
386
+ CBAM 不再通过后端返回确认状态。高风险请求如果绕过 Wrapper 或缺少 `confirmed=true`,后端返回
387
+ `FAILED / CONFIRMATION_REQUIRED`;Wrapper 应在调用 MCP 前完成审批,不能收到该错误后再补做审批并自动重试。
386
388
 
387
389
  ### 7.3 结构化错误
388
390
 
@@ -506,7 +508,9 @@ SALE_PRODUCT, CARBON_TAX, DATA_QUALITY
506
508
  | `email` | 否 | 邮箱 |
507
509
  | `mobile` | 否 | 手机号 |
508
510
 
509
- `action=create` 时省略 `factoryId`;`action=update` 时必须传 `factoryId`。创建和更新都需要 WAIT_CONFIRM。
511
+ `action=create` 时省略 `factoryId`;`action=update` 时必须传 `factoryId`。创建和更新都必须先经过现有 Agent 审批,批准后单次调用本工具。
512
+
513
+ 术语约束:中文会话、业务卡片和操作确认中统一称为“CBAM 工厂”或“工厂”,不得把 `factory` 翻译成“设施”。创建确认建议使用:“是否确认按上述信息创建 CBAM 工厂?本次确认仅包含工厂创建,不包含后续 CBAM 报告创建。”
510
514
 
511
515
  ### 8.5 `cbam_report_save`
512
516
 
@@ -645,30 +649,24 @@ SALE_PRODUCT, CARBON_TAX, DATA_QUALITY
645
649
 
646
650
  先读 `DATA_QUALITY`,再提交完整 `data`:`generalInformation`、`defaultReason`、`qualityAssurance`、`carbonPrice`、`supplement`。前三项使用 `CBAM_ENUM` 编码。
647
651
 
648
- ### 8.14 `cbam_report_generate` / `cbam_report_generation_status`
652
+ ### 8.14 `cbam_report_generate`
649
653
 
650
654
  生成前:
651
655
 
652
656
  1. 调用 `cbam_report_read(view=readiness)`。
653
657
  2. `canGenerate=false` 或存在 `blockers`:引导用户修复,不能调用生成。
654
658
  3. 只有 `warnings`:向用户说明报告可能不完整,但允许其继续生成。
655
- 4. 用户确认后执行两阶段生成。
659
+ 4. 调用 MCP 前复用现有 Agent 审批;用户批准后由 Wrapper 注入技术字段并单次发起生成。
656
660
 
657
- 生成成功启动时返回:`reportId`、`reportName`、`generationId`、`fileRecordId`、`status=RUNNING`。
661
+ Java 服务仍然异步生成文件,但 MCP 会在一次工具调用内使用内部状态路由等待最多 100 秒。生成任务触发使用固定 20 秒超时,触发与轮询共同受 120 秒端到端总预算约束;每次状态请求也不会超过当时的剩余预算。该状态路由不出现在 `tools/list`,Agent 不需要也不能直接调用。
658
662
 
659
- 轮询示例:
663
+ 正常完成时返回:`reportId`、`generationId`、`fileRecordId`、`status=COMPLETED`、`file`、`fileName` 和 `downloadUrl`。生成失败时 MCP 返回 `REPORT_GENERATION_FAILED`,并优先展示下载记录中的 `failureReason`。
660
664
 
661
- ```json
662
- {
663
- "sessionId": "session-001",
664
- "reportId": 9001,
665
- "generationId": 70001
666
- }
667
- ```
665
+ 如果 100 秒后 Java 后台仍在生成,工具返回正常的 `status=RUNNING`、`timedOut=true`、`generationId` 和 `retryWithSameIdempotencyKey=true`。后续使用完全相同的业务参数及 `idempotencyKey` 再调用 `cbam_report_generate`,Java 幂等记录会返回原 `generationId`,MCP 从该任务继续等待,不会创建第二份文件。
668
666
 
669
- 状态为 `RUNNING`、`COMPLETED` 或 `FAILED`。`COMPLETED` 时使用返回的 `file.path`;`FAILED` 时展示 `failureReason`。生成记录同步进入碳云下载管理,`module=cbam2`、`moduleDesc=CBAM2`。
667
+ 生成记录同步进入碳云下载管理,`module=cbam2`、`moduleDesc=CBAM2`。Agent 不自行实现固定间隔轮询,不自行生成另一份 Excel/Word。
670
668
 
671
- ## 9. WAIT_CONFIRM 两阶段确认
669
+ ## 9. 复用现有 Agent 审批
672
670
 
673
671
  以下操作必须确认:
674
672
 
@@ -677,40 +675,33 @@ SALE_PRODUCT, CARBON_TAX, DATA_QUALITY
677
675
  - 碳税 `calculate`;
678
676
  - 报告 `generate`。
679
677
 
680
- 第一阶段按正常业务参数调用,但不传 `confirmed=true`。返回:
678
+ 这些动作与产品碳、企业碳共用同一套审批弹框和 LangGraph interrupt,不新增 CBAM 专用弹框。正确时序:
681
679
 
682
- ```json
683
- {
684
- "success": false,
685
- "status": "WAIT_CONFIRM",
686
- "message": "confirmation required",
687
- "data": {
688
- "pendingActionId": "pa_xxx",
689
- "tool": "report/generate"
690
- },
691
- "error": null
692
- }
693
- ```
680
+ 1. 模型只生成业务参数,看不到也不填写 `confirmed`、`idempotencyKey`。
681
+ 2. Wrapper 在调用 MCP 前识别上述高风险动作,固定本次业务参数并生成稳定的 `idempotencyKey`。
682
+ 3. 使用当前 `thread_id/checkpoint` 发出现有审批 `interrupt`。
683
+ 4. 用户拒绝时结束动作,不调用 MCP。
684
+ 5. 用户批准时,Wrapper 在原业务参数上注入 `confirmed=true` 和原 `idempotencyKey`,单次调用 MCP。
694
685
 
695
- Agent 必须向用户清楚说明即将执行的动作及对象。用户确认后,第二阶段重复完全相同的业务请求:
686
+ 批准后的 MCP 请求示例:
696
687
 
697
688
  ```json
698
689
  {
699
690
  "sessionId": "session-001",
700
691
  "reportId": 9001,
701
692
  "idempotencyKey": "cbam-generate-9001-20260812-001",
702
- "confirmed": true,
703
- "pendingActionId": "pa_xxx"
693
+ "confirmed": true
704
694
  }
705
695
  ```
706
696
 
707
697
  规则:
708
698
 
709
- - `pendingActionId` 默认 30 分钟有效。
710
- - 第二次必须沿用相同 `idempotencyKey`。
711
- - 除 `confirmed`、`pendingActionId` 和追踪字段外,业务参数必须完全相同。
712
- - 参数变化会返回 `CONFIRMATION_PAYLOAD_MISMATCH`;此时重新发起第一阶段。
699
+ - 审批前不得调用 CBAM MCP,也不存在预调用或后端确认凭证。
700
+ - LangGraph 恢复会从中断节点开头重放;`interrupt` 之前不得执行远程写操作等非幂等副作用。
701
+ - 恢复必须使用同一 `thread_id/checkpoint`,并从状态中复用同一业务参数和 `idempotencyKey`。
702
+ - 用户在审批时修改了业务参数,应废弃旧审批,按新参数和新幂等键重新审批。
713
703
  - 用户拒绝或取消时,不再调用工具,也不要伪造“取消接口”。
704
+ - CBAM 后端仍校验高风险动作必须为 `confirmed=true`,用于防止绕过审批 Wrapper 的直接调用。
714
705
 
715
706
  ## 10. 幂等、并发与重试
716
707
 
@@ -719,7 +710,7 @@ Agent 必须向用户清楚说明即将执行的动作及对象。用户确认
719
710
  - 同一个用户业务动作重试时复用原键;新的业务动作生成新键。
720
711
  - 相同键、相同请求返回原结果;相同键、不同请求返回 `IDEMPOTENCY_CONFLICT`。
721
712
  - CBAM 写工具在 MCP 层全部关闭自动重试,避免超时后重复写入。
722
- - 报告生成超时下限为 120 秒;网络超时不代表服务端一定失败,应先用生成状态或报告快照核对。
713
+ - `cbam_report_generate` 的 MCP 端到端预算为 120 秒;Agent MCP Client、反向代理和网关超时应配置为大于 120 秒。网络超时不代表服务端一定失败,后续必须复用相同业务参数和幂等键继续调用,或通过报告快照核对,不能创建重复任务。
723
714
  - `RESOURCE_BUSY` 和 `IDEMPOTENCY_IN_PROGRESS` 属于可恢复状态;退避后查状态,避免并发写同一报告。
724
715
 
725
716
  推荐幂等键:
@@ -768,10 +759,11 @@ Agent 必须执行新的 `cbam_report_save(action=create)`。创建完成后,
768
759
  1. 明确 `reportId`。
769
760
  2. 读取 `readiness`。
770
761
  3. 有阻断项则补齐;只有提示则解释提示并询问是否继续。
771
- 4. 第一次调用 `cbam_report_generate` 得到 `WAIT_CONFIRM`。
772
- 5. 用户确认后,用相同业务参数和幂等键、加 `pendingActionId` 再调用。
773
- 6. 获取 `generationId` 后轮询 `cbam_report_generation_status`。
774
- 7. 完成后展示下载地址和报告卡片;不要自行生成第二份 Excel/Word。
762
+ 4. 调用 MCP 前使用现有 LangGraph interrupt 请求用户确认。
763
+ 5. 用户确认后,由 Wrapper 注入 `confirmed=true` 和稳定幂等键,单次调用 `cbam_report_generate`。
764
+ 6. MCP 内部等待生成结果;`COMPLETED` 时直接取得下载地址,Agent 不调用状态轮询工具。
765
+ 7. 极端情况下返回 `RUNNING + timedOut=true`,后续使用同一幂等键重调 `cbam_report_generate` 继续等待原任务。
766
+ 8. 完成后展示下载地址和报告卡片;不要自行生成第二份 Excel/Word。
775
767
 
776
768
  ## 12. Agent 编排约束
777
769
 
@@ -784,8 +776,8 @@ Agent 必须执行新的 `cbam_report_save(action=create)`。创建完成后,
784
776
  3. 组织、工厂、字典、产品类别、CN 和默认数据只能使用工具返回值。
785
777
  4. 修改完整表单前先读取当前值,保留未修改字段。
786
778
  5. 只把 readiness.blockers 当成生成阻断;warnings 需要告知但不强制阻断。
787
- 6. WAIT_CONFIRM 时先向用户确认,确认后原样复用业务参数、idempotencyKey 和 pendingActionId。
788
- 7. 所有写操作禁止盲目自动重试;超时后先查询状态。
779
+ 6. 高风险动作在调用 MCP 前使用现有审批 interrupt;批准后由 Wrapper 注入 confirmed=true 和稳定 idempotencyKey。
780
+ 7. 所有写操作禁止盲目自动重试;报告生成返回 timedOut 时,只能使用相同参数和幂等键重调 cbam_report_generate 继续等待原任务。
789
781
  8. 不自行计算 CBAM 排放、碳税或生成报告文件,以服务端结果为准。
790
782
  9. 工具失败时依据 error.fieldPath/itemIndex 引导修正,不虚构成功结果。
791
783
  10. 每次写成功后更新当前 reportId,并在需要时刷新 snapshot/section。
@@ -796,7 +788,7 @@ Agent 必须执行新的 `cbam_report_save(action=create)`。创建完成后,
796
788
  - 一次只问当前步骤真正缺少的字段,不把整个 CBAM 表单一次性抛给用户。
797
789
  - 对枚举优先展示多语言名称,但提交时使用返回编码。
798
790
  - 对分页引用数据支持继续搜索和翻页。
799
- - 批量保存前用自然语言复述将要保存的行;普通保存无需额外 WAIT_CONFIRM。
791
+ - 批量保存前用自然语言复述将要保存的行;普通保存不增加审批。
800
792
  - 不主动修改与用户目标无关的区块。
801
793
 
802
794
  ## 13. 权限、组织与数据安全
@@ -814,7 +806,7 @@ Agent 必须执行新的 `cbam_report_save(action=create)`。创建完成后,
814
806
  - 字典和引用数据统一由 `cbam_reference_search` 返回当前语言的展示名称及稳定编码。
815
807
  - Agent 展示名称,提交编码;禁止把中文名称直接当编码。
816
808
  - 单位字段沿用 CBAM/碳云单位约定,保存前使用引用数据或当前区块返回的单位值,不自创单位编码。
817
- - 证明材料等已有业务文件仍由 CBAM 文件适配层处理;MCP 不接收本地文件路径作为本次 16 个工具的输入。
809
+ - 证明材料等已有业务文件仍由 CBAM 文件适配层处理;MCP 不接收本地文件路径作为本次 15 个工具的输入。
818
810
  - 报告生成由 CBAM 服务上传文件并写入基础框架 `report_file`,下载列表通过 `module=cbam2` 展示。
819
811
 
820
812
  ## 15. 联调验收清单
@@ -843,13 +835,14 @@ Agent 必须执行新的 `cbam_report_save(action=create)`。创建完成后,
843
835
  - [ ] `include=0` 展示热电联产,`include=1` 跳过。
844
836
  - [ ] 碳税计算确认后返回异步任务,并能轮询到终态。
845
837
  - [ ] readiness 的 blocker 与 warning 被区别处理。
846
- - [ ] 报告生成确认后能轮询到 `COMPLETED`。
838
+ - [ ] 报告生成确认后,单次 MCP 调用能由内部轮询返回 `COMPLETED`,Agent 工具列表不暴露生成状态接口。
847
839
  - [ ] 生成文件在碳云下载管理中显示成功,`path` 非空。
848
840
 
849
841
  ### 15.4 安全与稳定性
850
842
 
851
- - [ ] 删除、工厂写入、碳税计算和生成均执行 WAIT_CONFIRM。
852
- - [ ] 确认第二次调用复用相同业务参数和幂等键。
843
+ - [ ] 删除、工厂写入、碳税计算和生成均复用现有 Agent 审批弹框。
844
+ - [ ] 审批前未调用 MCP,批准后只调用一次且携带 `confirmed=true`。
845
+ - [ ] LangGraph 恢复使用相同 thread/checkpoint 和幂等键,不重复执行业务写入。
853
846
  - [ ] 相同幂等键重复调用不产生重复数据。
854
847
  - [ ] 同键不同参数返回冲突。
855
848
  - [ ] 跨组织/跨报告子资源 ID 被拒绝。
@@ -858,7 +851,7 @@ Agent 必须执行新的 `cbam_report_save(action=create)`。创建完成后,
858
851
 
859
852
  ## 16. 31 个内部接口映射(排障用)
860
853
 
861
- MCP 正常接入时只调用 16 个工具;以下路径仅用于服务端排障:
854
+ MCP 正常接入时只调用 15 个工具;以下路径仅用于服务端排障:
862
855
 
863
856
  ```text
864
857
  cbam_reference_search
@@ -921,7 +914,7 @@ cbam_data_quality_update
921
914
  cbam_report_generate
922
915
  -> /cbam2/agent/internal/skills/cbam/report/generate
923
916
 
924
- cbam_report_generation_status
917
+ MCP 内部状态路由(不向 Agent 暴露)
925
918
  -> /cbam2/agent/internal/skills/cbam/report/generation/status
926
919
  ```
927
920
 
@@ -9,9 +9,9 @@ Scope: the `tools/list.inputSchema` contract and deterministic MCP-side validati
9
9
  | Baseline | Version | Tools | Payload | `anyOf` | `oneOf` | `allOf` | `not` | `if` | `then` |
10
10
  |---|---:|---:|---:|---:|---:|---:|---:|---:|---:|
11
11
  | Test endpoint before this change | 0.1.38 | 39 | 174,877 bytes | 78 | 0 | 0 | 0 | 0 | 0 |
12
- | Local working tree | 0.1.46 | 71 | 283,179 bytes | 321 | 0 | 4 | 31 | 7 | 7 |
12
+ | Local working tree | 0.1.48 | 70 | 284,035 bytes | 318 | 0 | 4 | 31 | 7 | 7 |
13
13
 
14
- The local tool count includes four `project_memory_*` tools, eleven `project_*` runtime-read tools, the confirmed `project_enterprise_task_create` write tool, and sixteen task-oriented `cbam_*` tools. Those sixteen tools route to all 31 CBAM Java atomic endpoints. The local payload is measured with `Buffer.byteLength(JSON.stringify(await client.listTools()))`; it excludes HTTP/SSE framing and is not a model-token count. The older test-endpoint baseline preserves its original endpoint-response measurement, so use that comparison as directional rather than byte-for-byte.
14
+ The local tool count includes four `project_memory_*` tools, eleven `project_*` runtime-read tools, the confirmed `project_enterprise_task_create` write tool, and fifteen task-oriented `cbam_*` tools. Those fifteen tools route to all 31 CBAM Java atomic endpoints; the generation-status endpoint is used internally by `cbam_report_generate` and is absent from `tools/list`. The local payload is measured with `Buffer.byteLength(JSON.stringify(await client.listTools()))`; it excludes HTTP/SSE framing and is not a model-token count. The older test-endpoint baseline preserves its original endpoint-response measurement, so use that comparison as directional rather than byte-for-byte.
15
15
 
16
16
  Some optional fields retain MCP-side blank/null-to-omitted normalization for compatibility with older callers. For those fields, the public Schema advertises the tolerated placeholders so strict MCP clients and server-side normalization agree. Agents should still prefer omission over generating blank or null values.
17
17
 
@@ -32,7 +32,7 @@ Some optional fields retain MCP-side blank/null-to-omitted normalization for com
32
32
  | `cbam_report_search` | Read | **Covered**: typed optional filters and pagination. | **Workflow/State**: user selection when multiple reports match; report visibility. |
33
33
  | `cbam_report_read` | Read | **Contract**: unified view enum; section and item dependencies; exact report/item ids. | **State**: report visibility and child ownership. |
34
34
  | `cbam_factory_read` | Read | **Covered**: exact factory id. | **State**: company and organization visibility. |
35
- | `cbam_factory_save` | Write | **Contract**: create/update action, conditional factory id, complete form, idempotency, confirmed retry requires pending action id; no automatic retry. | **State/Workflow**: shared-data WAIT_CONFIRM, immutable org, dictionary/code uniqueness. |
35
+ | `cbam_factory_save` | Write | **Contract**: create/update action, conditional factory id, complete form, wrapper-injected idempotency and `confirmed=true`; no automatic retry. | **State/Workflow**: reuse existing Agent approval before the single MCP call; immutable org, dictionary/code uniqueness. |
36
36
  | `cbam_report_save` | Write | **Contract**: create/update action, conditional report id, complete base form, exact calendar range, idempotency. | **Workflow/State**: every create adds a new session-bound report; organization/factory visibility. |
37
37
  | `cbam_process_manage` | Write | **Contract**: save/delete/reorder action payloads, unique ids, limits, delete confirmation. | **State**: dependencies, references, complete reorder set, report ownership. |
38
38
  | `cbam_precursor_manage` | Write | **Contract**: save/delete payloads, unique ids, limits, delete confirmation. | **State**: category/country validity and report ownership. |
@@ -42,8 +42,7 @@ Some optional fields retain MCP-side blank/null-to-omitted normalization for com
42
42
  | `cbam_sale_product_manage` | Write | **Contract**: save/delete payloads, form fields, exact ids, calculated/attachment fields absent, delete confirmation. | **State**: process/category/CN references and dependent tax rows. |
43
43
  | `cbam_carbon_tax_manage` | Write | **Contract**: save/delete/calculate payloads, exact ids/codes, delete/calculate confirmation. | **State**: candidates, currencies, running calculation task, backend formula. |
44
44
  | `cbam_data_quality_update` | Write | **Covered**: complete Agent-safe quality fields; ownership/calculated fields absent. | **State/Workflow**: read-before-full-update and report ownership. |
45
- | `cbam_report_generate` | Write | **Contract**: exact report id, idempotency, confirmed retry requires pending action id, 120-second timeout, no automatic retry. | **Workflow/State**: WAIT_CONFIRM, asynchronous generation, readiness and download record. |
46
- | `cbam_report_generation_status` | Read | **Covered**: exact report and generation ids. | **State**: task belongs to report and current company. |
45
+ | `cbam_report_generate` | Write | **Contract**: exact report id, wrapper-injected idempotency and `confirmed=true`, no write retry; the asynchronous start has an exact 20-second timeout and MCP internally polls for up to 100 seconds inside one 120-second total budget. | **Workflow/State**: reuse existing Agent approval before the single MCP call; Java generation remains asynchronous, while the status endpoint is internal and validates task/report/company ownership. |
47
46
  | `user_memory_recall` | Read | **Covered**: identity, query length, type filter, limit. | **State**: message/session ownership. |
48
47
  | `user_memory_get` | Read | **Covered**: exact `memoryId`. | **State**: memory ownership and visibility. |
49
48
  | `user_memory_upsert` | Write | **Covered**: scope/type/source/recall enums, key pattern, content length, confidence ranges. Compatibility permits omitted/zero version. | **Workflow/State**: recall-first workflow, semantic duplicate detection, optimistic-lock state. |
@@ -167,7 +166,7 @@ Ordinary Zod field/type failures are MCP protocol `-32602` errors and are also n
167
166
  `npm run test:schema` verifies:
168
167
 
169
168
  1. A real in-memory MCP `initialize` and `tools/list` flow.
170
- 2. Exactly 71 exposed tools in the current working tree, including 16 CBAM task tools covering 31 Java endpoints.
169
+ 2. Exactly 70 exposed tools in the current working tree, including 15 public CBAM task tools covering 31 Java endpoints through one internal generation-status route.
171
170
  3. Draft-07 metadata validity, object roots, declared required properties, and resolvable local refs.
172
171
  4. One generated minimum-valid public-Schema fixture per tool.
173
172
  5. Save/update valid and invalid factor-mode matrices.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carbonstopper/agent-mcp",
3
- "version": "0.1.48",
3
+ "version": "0.1.50",
4
4
  "description": "MCP server for Carbonstop Agent internal skill APIs",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",