Skip to main content
Glama

scan_project

Performs comprehensive security scans on project directories to identify vulnerabilities and ensure compliance with industry standards like OWASP, CIS, and NIST frameworks.

Instructions

Performs comprehensive security scan on project directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
incrementalNoUse incremental scanning if available
pathYesProject path to scan
profileNoScan profile
toolsNoSpecific tools to use

Implementation Reference

  • Primary MCP tool handler for 'scan_project'. Validates input, enforces boundaries, supports incremental scanning, applies false positive filtering, and delegates core scanning to ProjectScanner.scan()
    private async handleProjectScan(args: any): Promise<ScanResult> {
      const { path, profile = 'standard', tools, incremental = false } = args;
    
      // Validate project boundaries
      const validation = await this.boundaryEnforcer.validatePath(path);
      if (!validation.allowed) {
        throw new McpError(ErrorCode.InvalidRequest, validation.reason || 'Path validation failed');
      }
    
      // Perform scan
      const request: ScanRequest = {
        type: 'project',
        target: path,
        profile,
        tools,
        options: {
          maxTokens: this.tokenManager.getRemainingTokens(),
          incremental,
        },
      };
    
      // Use incremental scanner if requested
      if (incremental && this.incrementalScanner) {
        const result = await this.incrementalScanner.scan(request);
        
        // Apply false positive filtering
        if (this.falsePositiveFilter) {
          const filterResults = await this.falsePositiveFilter.filterFindings(result.findings);
          result.findings = filterResults.filter(r => !r.filtered).map(r => r.finding);
          
          // Add filter stats to result
          const filterStats = this.falsePositiveFilter.getStatistics(filterResults);
          console.error(`Filtered ${filterStats.filtered} false positives (${filterStats.filterRate.toFixed(1)}%)`);
        }
        
        return result;
      }
    
      // Regular scan
      const result = await this.projectScanner.scan(request);
      
      // Apply false positive filtering
      if (this.falsePositiveFilter) {
        const filterResults = await this.falsePositiveFilter.filterFindings(result.findings);
        result.findings = filterResults.filter(r => !r.filtered).map(r => r.finding);
      }
      
      return result;
    }
  • Core implementation of project scanning logic. Orchestrates multiple security tools (Semgrep, Trivy, Gitleaks, Checkov, etc.), supports caching, parallel execution, and aggregates findings from all scanners.
    async scan(request: ScanRequest): Promise<ScanResult> {
      const scanId = this.generateScanId();
      const startTime = Date.now();
    
      // Validate boundaries
      const validation = await this.boundaryEnforcer.validatePath(request.target);
      if (!validation.allowed) {
        throw new Error(`Boundary violation: ${validation.reason}`);
      }
    
      // Determine which tools to run
      const tools = request.tools || this.getDefaultTools(request.profile);
      
      // Check cache first
      const cachedResult = await this.cache.get('project', request.target, tools, request.profile);
      if (cachedResult) {
        console.error(`Cache hit for project scan: ${scanId}`);
        // Update scan ID and timing for the cached result
        cachedResult.scanId = scanId;
        cachedResult.scanTimeMs = Date.now() - startTime;
        return cachedResult;
      }
    
      console.error(`Starting project scan: ${scanId} with tools: ${tools.join(', ')}`);
    
      const allFindings: Finding[] = [];
      const errors: string[] = [];
      let tokenUsage = 0;
    
      // Determine execution strategy
      const useParallel = request.options?.parallel !== false && tools.length > 1;
      
      if (useParallel) {
        // Run scanners in parallel
        const scanResults = await this.runScannersInParallel(request.target, tools);
        
        // Aggregate results
        for (const result of scanResults.results) {
          if (result.status === 'success' && result.result) {
            allFindings.push(...result.result.findings);
            tokenUsage += result.result.tokenUsage;
          } else if (result.status === 'error') {
            const errorMsg = `${result.id} failed: ${result.error?.message}`;
            console.error(errorMsg);
            errors.push(errorMsg);
          }
        }
      } else {
        // Run scanners sequentially
        for (const tool of tools) {
          try {
            console.error(`Running ${tool} scanner...`);
            
            const scanResult = await this.runSingleScanner(tool, request.target);
            allFindings.push(...scanResult.findings);
            tokenUsage += scanResult.tokenUsage;
            
          } catch (error) {
            const errorMsg = `${tool} failed: ${error instanceof Error ? error.message : 'Unknown error'}`;
            console.error(errorMsg);
            errors.push(errorMsg);
          }
        }
      }
    
      // Calculate summary
      const summary = this.calculateSummary(allFindings);
    
      const result: ScanResult = {
        scanId,
        status: errors.length === 0 ? 'success' : (allFindings.length > 0 ? 'partial' : 'failed'),
        summary,
        findings: allFindings,
        tokenUsage,
        scanTimeMs: Date.now() - startTime,
        errors: errors.length > 0 ? errors : undefined,
      };
    
      // Cache successful results
      if (result.status === 'success') {
        await this.cache.set('project', request.target, tools, result, request.profile);
      }
    
      console.error(`Project scan completed: ${result.status}, ${allFindings.length} findings`);
      return result;
    }
  • Tool registration and input schema definition for 'scan_project' in the MCP tools list returned by ListToolsRequestHandler.
    {
      name: 'scan_project',
      description: 'Performs comprehensive security scan on project directory',
      inputSchema: {
        type: 'object',
        properties: {
          path: { type: 'string', description: 'Project path to scan' },
          profile: { 
            type: 'string', 
            enum: ['quick', 'standard', 'thorough'],
            description: 'Scan profile'
          },
          tools: {
            type: 'array',
            items: { type: 'string' },
            description: 'Specific tools to use'
          },
          incremental: {
            type: 'boolean',
            description: 'Use incremental scanning if available'
          },
        },
        required: ['path'],
      },
  • Tool dispatch registration in the central CallToolRequestHandler switch statement.
    switch (name) {
      case 'scan_project':
        result = await this.handleProjectScan(args);
        break;
  • Helper function that dispatches to individual scanner implementations (Semgrep, Trivy, Gitleaks, etc.) based on tool name.
    private async runSingleScanner(tool: string, targetPath: string): Promise<{ findings: Finding[]; tokenUsage: number }> {
      switch (tool) {
        case 'semgrep':
          return await this.runSemgrep(targetPath);
        case 'trivy':
          return await this.runTrivy(targetPath);
        case 'gitleaks':
          return await this.runGitleaks(targetPath);
        case 'checkov':
          return await this.runCheckov(targetPath);
        case 'nuclei':
          return await this.runNuclei(targetPath);
        case 'bandit':
          return await this.runBandit(targetPath);
        case 'grype':
          return await this.runGrype(targetPath);
        case 'custom_rules':
          return await this.runCustomRules(targetPath);
        case 'owasp_dependency_check':
          return await this.runOwaspDependencyCheck(targetPath);
        default:
          throw new Error(`Unknown scanner tool: ${tool}`);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While 'performs comprehensive security scan' implies a read-only analysis operation, it doesn't specify whether this requires special permissions, has side effects (e.g., generating logs), involves rate limits, or what the output format might be. The description is too minimal for a tool with security implications.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's appropriately sized for a tool with good schema documentation and gets straight to the point without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a security scanning tool with no annotations and no output schema, the description is inadequate. It doesn't explain what 'comprehensive' means, what security aspects are scanned, what the typical output contains, or how this differs from sibling tools. Given the complexity of security operations, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all four parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema, meeting the baseline expectation when structured data does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('performs comprehensive security scan') and target ('on project directory'), providing a specific verb+resource combination. However, it doesn't explicitly distinguish this tool from sibling tools like 'check_compliance' or 'pentest_application', which might also involve security assessments.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'check_compliance' or 'pentest_application'. It doesn't mention prerequisites, appropriate contexts, or exclusions, leaving the agent with no usage differentiation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/NeoTecDigital/mcp_shamash'

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