Skip to main content
Glama

scan_project

Analyze project files to detect CSS/JS features and check browser compatibility for specified targets, helping identify potential compatibility issues.

Instructions

Analyze project files to detect CSS/JS features and check compatibility across browser targets

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathNoPath to the project directory to scan (default: current directory).
targetsNoBrowser targets to check (e.g., 'chrome-37', 'firefox-esr', 'safari-12')
maxDepthNoMaximum directory depth to scan
excludeDirsNoDirectories to exclude from scanning

Implementation Reference

  • The handler function that implements the core logic of the 'scan_project' tool. It processes input arguments, invokes the compatibility checker on the project, and returns a formatted response with scan results, compatibility scores, and recommendations.
    export async function handleScanProject(args) {
      const {
        projectPath = '.',
        targets = ['chrome-37'],
        maxDepth = 5,
        excludeDirs = ['node_modules', '.git', 'dist', 'build']
      } = args;
    
      const scanOptions = {
        maxDepth,
        excludeDirs
      };
    
      const result = await compatibilityChecker.checkProjectCompatibility(
        projectPath, 
        { targets, scanOptions, includeRecommendations: true }
      );
    
      // Format for better UX
      return {
        status: result.status || 'completed',
        project: {
          path: projectPath,
          scanned: `${result.projectScan?.totalFiles || 0} files`,
          jsFiles: result.projectScan?.jsFiles || 0,
          cssFiles: result.projectScan?.cssFiles || 0,
          featuresDetected: result.features?.length || 0
        },
        compatibility: {
          targets: Object.keys(result.compatibility || {}),
          overallScore: result.summary?.overallScore || 100,
          criticalIssues: result.summary?.criticalIssues?.length || 0,
          commonUnsupported: result.summary?.commonUnsupported || []
        },
        recommendations: result.recommendations || [],
        nextSteps: result.nextSteps || [],
        detailedResults: {
          features: result.features,
          targetResults: result.compatibility,
          summary: result.summary
        }
      };
    }
  • index.js:15-50 (registration)
    Registers the 'scan_project' tool with the MCP server, defining its metadata, input schema, and the wrapper handler that calls the core handleScanProject function and formats the MCP response.
    server.registerTool(
      "scan_project",
      {
        title: "Project Scanner",
        description: "Analyze project files to detect CSS/JS features and check compatibility across browser targets",
        inputSchema: {
          projectPath: z.string().optional().default(".").describe("Path to the project directory to scan (default: current directory)"),
          targets: z.array(z.string()).optional().default(["chrome-37"]).describe("Browser targets to check (e.g., 'chrome-37', 'firefox-esr', 'safari-12')"),
          maxDepth: z.number().optional().default(5).describe("Maximum directory depth to scan"),
          excludeDirs: z.array(z.string()).optional().default(["node_modules", ".git", "dist", "build"]).describe("Directories to exclude from scanning")
        }
      },
      async (args) => {
        try {
          const result = await handleScanProject(args);
          return {
            content: [{
              type: "text",
              text: JSON.stringify(result, null, 2)
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                error: true,
                message: error.message,
                suggestion: "Try using 'scan_project' to automatically detect and check your project's compatibility."
              }, null, 2)
            }],
            isError: true
          };
        }
      }
    );
  • Zod-based input schema defining the parameters for the 'scan_project' tool, including project path, browser targets, scan depth, and exclusion rules.
    inputSchema: {
      projectPath: z.string().optional().default(".").describe("Path to the project directory to scan (default: current directory)"),
      targets: z.array(z.string()).optional().default(["chrome-37"]).describe("Browser targets to check (e.g., 'chrome-37', 'firefox-esr', 'safari-12')"),
      maxDepth: z.number().optional().default(5).describe("Maximum directory depth to scan"),
      excludeDirs: z.array(z.string()).optional().default(["node_modules", ".git", "dist", "build"]).describe("Directories to exclude from scanning")
    }

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/Amirmahdi-Kaheh/caniuse-mcp'

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