用途:为 pingidentity/aic-mcp-server 代码库提供代码审查清单与常见陷阱,触发场景为审查 PR 或工具实现。
主要能力:按优先级给出审查维度——安全(路径穿越、scope 正确性、错误信息泄露)、正确性(API 契约、响应格式、错误处理)、约定(helper 使用、命名、注解、测试结构)、质量(可读性、重复、边界情况)。
工具实现清单:SCOPES 需为模块级 const 并同时传给工具对象与 makeAuthenticatedRequest();用户提供的路径段须用 safePathSegmentSchema 校验;API 调用须用 makeAuthenticatedRequest() 而非原始 fetch;返回须经 createToolResponse(),成功响应用 formatSuccess(data, response) 以包含 transaction ID;错误处理用 catch (error: any) 返回 createToolResponse('Failed to ...: ${error.message}');Realm 参数用 validationHelpers 的 z.enum(REALMS);导出名遵循 <toolName>Tool;DELETE 操作加 annotations: { destructiveHint: true };幂等 PUT/PATCH 加 annotations: { idempotentHint: true }。
常见陷阱:URL 路径中 ID 参数未用 safePathSegmentSchema;DELETE 或破坏性操作缺少 destructiveHint;scope 内联硬编码而非引用 SCOPES;直接返回 JSON.stringify(data) 丢失 transaction ID;主题更新/删除未保留 isDefault 等 realm 数据;AM 工具未使用 amHelpers 的 buildAMRealmUrl() 与 AM_API_HEADERS。
测试审查清单:需有快照测试(snapshotTest());章节顺序为 Snapshot、Request Construction、Response Handling、Input Validation、Error Handling;复杂编排工具在 Snapshot 后加 Application Logic;请求构造测试通过 spy 验证 URL、scopes、method、body;含 ID 参数的工具需路径穿越测试('../etc/passwd' 应抛错);接受用户 filter/query 的工具需查询注入测试;错误处理测试覆盖 401、403、404;用 server.use() 配置 MSW handler。
验证命令:npm test、npm run typecheck、npm run lint、npm run format:check、npm run build、npm run test:snapshots:update(工具 schema 变更时)。
限制:资料未提供该技能的具体安装方式、收费与平台信息。