Skip to main content
Glama

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
NameRequiredDescriptionDefault
baseYesBase branch (e.g. 'origin/main')
headYesHead branch (e.g. 'HEAD')
pathYesRepository path
levelNoSLA levelL1

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"),
    });
  • Registration of the `scan_diff` tool in the server request handler.
    case "scan_diff": {
      const parsed = scanDiffSchema.parse(args);
      return handleScanDiff(parsed);
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/raye-deng/open-code-review'

If you have feedback or need assistance with the MCP directory API, please join our Discord server