scan_diff
Analyze git diff between branches to identify code quality issues in changed files and lines for PR/MR reviews.
Instructions
Scan git diff between two branches for code quality issues. Ideal for PR/MR review — only analyzes changed files and lines.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| base | Yes | Base branch (e.g. 'origin/main') | |
| head | Yes | Head branch (e.g. 'HEAD') | |
| path | Yes | Repository path | |
| level | No | SLA level | L1 |
Implementation Reference
- The handler function `handleScanDiff` executes the `scan_diff` tool logic by calling `runDiffScan` and formatting the output.
export async function handleScanDiff(args: z.infer<typeof scanDiffSchema>) { const { result, diffResult } = await runDiffScan(args.path, args.base, args.head, args.level); return { content: [ { type: "text" as const, text: JSON.stringify({ version: "4.0", mode: "diff", base: args.base, head: args.head, changedFiles: diffResult.files.map((f) => ({ path: f.path, status: f.status, additions: f.additions, deletions: f.deletions, })), sla: result.sla, files: result.files, durationMs: result.durationMs, issuesCount: result.issues.length, issues: result.issues.map((issue) => ({ detectorId: issue.detectorId, file: issue.file, line: issue.line, endLine: issue.endLine ?? null, severity: issue.severity, category: issue.category, message: issue.message, confidence: issue.confidence, })), }, null, 2), }, ], }; } - The Zod schema `scanDiffSchema` defines the input validation for the `scan_diff` tool.
export const scanDiffSchema = z.object({ base: z.string().describe("Base branch (e.g. 'origin/main')"), head: z.string().describe("Head branch (e.g. 'HEAD')"), path: z.string().describe("Repository path"), level: z.enum(["L1", "L2", "L3"]).optional().default("L1").describe("SLA level"), }); - packages/mcp-server/src/server.ts:135-138 (registration)Registration of the `scan_diff` tool in the server request handler.
case "scan_diff": { const parsed = scanDiffSchema.parse(args); return handleScanDiff(parsed); }