Skip to main content
Glama

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
NameRequiredDescriptionDefault
pathYesDirectory path to scan
levelNoSLA level: L1 (fast structural), L2 (standard + local AI), L3 (deep + remote AI)L1
languagesNoComma-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')"),
    });
  • 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"],
      },
    },
  • The tool 'scan_directory' is registered in the 'CallToolRequestSchema' handler switch case.
    case "scan_directory": {
      const parsed = scanDirectorySchema.parse(args);
      return handleScanDirectory(parsed);
    }

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

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