mcp-server.factory.ts
7.67 KB
-
refactor(mcp): 评审小瑕疵清理 + 修 list_recall_queue clinicId 静默失效 · c9743ed0
评审发现的 4 处小瑕疵: 1. 工具清单进程级缓存(McpClientService.toolsCache)— 工具静态、与租户无关,省每轮 tools/list 往返。 2. list_recall_queue 去掉 `as unknown as ListPlansQueryDto` 强转,改类型化字面量; 过程中发现隐藏 bug:schema 字段是 targetClinicId 而非 clinicId,旧 cast 把 clinicId 静默吞掉 → 工具的诊所过滤一直没生效。改用 targetClinicId,验证 271→96 条且全为该诊所。 3. McpClientService.url 注释澄清:同进程 loopback,PORT 与 main.ts 监听端口一致(默认 3001)。 4. get_facts 加注释说明经 getTimeline 自守(findFirst{host,tenant}+NotFound),与其它工具显式 assert 等价安全; 顶部注释据实修正两条隔离路径。 tsc 0;端到端验证:6 工具正常 + clinicId 过滤生效。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>luoqi committed