scan_directory
Scan directories to detect AI-generated code quality issues like hallucinated imports, phantom packages, stale APIs, and security anti-patterns across multiple programming languages.
Instructions
Scan a directory for AI-generated code quality issues. Detects hallucinated imports, phantom packages, stale APIs, security anti-patterns, and more. Supports TypeScript, JavaScript, Python, Java, Go, and Kotlin.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Directory path to scan | |
| level | No | SLA level: L1 (fast structural), L2 (standard + local AI), L3 (deep + remote AI) | L1 |
| languages | No | Comma-separated languages (e.g. 'typescript,python'). Auto-detect if omitted. |
Implementation Reference
- The 'handleScanDirectory' function executes the logic for the 'scan_directory' tool.
export async function handleScanDirectory(args: z.infer<typeof scanDirectorySchema>) { const languages = args.languages ? args.languages.split(",").map((s) => s.trim()) : undefined; const result = await runScan(args.path, args.level, languages); return { content: [ { type: "text" as const, text: JSON.stringify({ version: "4.0", sla: result.sla, files: result.files, languages: result.languages, 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 'scanDirectorySchema' zod schema defines the input validation for 'scan_directory'.
export const scanDirectorySchema = z.object({ path: z.string().describe("Directory path to scan"), level: z.enum(["L1", "L2", "L3"]).optional().default("L1").describe("SLA level: L1 (fast), L2 (standard), L3 (deep)"), languages: z.string().optional().describe("Comma-separated languages to scan (e.g. 'typescript,python')"), }); - packages/mcp-server/src/server.ts:31-54 (registration)The 'scan_directory' tool is defined in the list of tools offered by the MCP server.
{ name: "scan_directory", description: "Scan a directory for AI-generated code quality issues. Detects hallucinated imports, phantom packages, stale APIs, security anti-patterns, and more. Supports TypeScript, JavaScript, Python, Java, Go, and Kotlin.", inputSchema: { type: "object" as const, properties: { path: { type: "string", description: "Directory path to scan" }, level: { type: "string", enum: ["L1", "L2", "L3"], default: "L1", description: "SLA level: L1 (fast structural), L2 (standard + local AI), L3 (deep + remote AI)", }, languages: { type: "string", description: "Comma-separated languages (e.g. 'typescript,python'). Auto-detect if omitted.", }, }, required: ["path"], }, }, - packages/mcp-server/src/server.ts:131-134 (registration)The tool 'scan_directory' is registered in the 'CallToolRequestSchema' handler switch case.
case "scan_directory": { const parsed = scanDirectorySchema.parse(args); return handleScanDirectory(parsed); }