Skip to main content
Glama

check_compliance

Validate project compliance against security frameworks like OWASP, CIS, NIST, and ISO27001 to ensure adherence to required standards and identify potential gaps.

Instructions

Validates project against compliance frameworks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
frameworksYesCompliance frameworks to check
pathYesProject path
profileNoCompliance check profile (default: standard)

Implementation Reference

  • MCP tool handler for check_compliance that validates input path, delegates to ComplianceValidator for scanning and framework mapping, generates HTML report, and formats the response.
    private async handleComplianceCheck(args: any): Promise<any> {
      const { path, frameworks, profile = 'standard' } = args;
    
      // Validate path
      const validation = await this.boundaryEnforcer.validatePath(path);
      if (!validation.allowed) {
        throw new McpError(ErrorCode.InvalidRequest, validation.reason || 'Path validation failed');
      }
    
      // Set the project scanner for the compliance validator
      this.complianceValidator.setProjectScanner(this.projectScanner);
    
      // Check compliance - this will run scans and map to frameworks
      const report = await this.complianceValidator.validate(path, frameworks, profile);
    
      // Generate HTML report
      const htmlPath = await this.complianceValidator.generateHTMLReport(report);
    
      // Return simplified result for MCP response
      return {
        status: 'success',
        summary: {
          overallCompliance: `${report.summary.overallCompliance}%`,
          totalFindings: report.summary.totalFindings,
          criticalFindings: report.summary.criticalFindings,
          highFindings: report.summary.highFindings,
        },
        frameworks: report.frameworks.map(f => ({
          name: f.framework,
          coverage: `${f.coverage}%`,
          passed: f.passed,
          failed: f.failed,
          total: f.totalControls,
        })),
        recommendations: report.summary.recommendations.slice(0, 5),
        reportPath: htmlPath,
        tokenUsage: report.scanResults?.tokenUsage || 0,
      };
    }
  • Input schema for the check_compliance tool defining parameters: path (required), frameworks (required array of OWASP/CIS/NIST/ISO27001), and optional profile.
      name: 'check_compliance',
      description: 'Validates project against compliance frameworks',
      inputSchema: {
        type: 'object',
        properties: {
          path: { type: 'string', description: 'Project path' },
          frameworks: {
            type: 'array',
            items: { 
              type: 'string',
              enum: ['OWASP', 'CIS', 'NIST', 'ISO27001']
            },
            description: 'Compliance frameworks to check'
          },
          profile: {
            type: 'string',
            enum: ['minimal', 'standard', 'comprehensive'],
            description: 'Compliance check profile (default: standard)'
          },
        },
        required: ['path', 'frameworks'],
      },
    },
  • Registration of the check_compliance tool handler in the switch statement within the CallToolRequestSchema handler.
    case 'check_compliance':
      result = await this.handleComplianceCheck(args);
      break;
  • Core compliance validation logic: performs project scan, maps findings to specified frameworks using ComplianceMapper, calculates compliance metrics, generates recommendations and report.
    async validate(
      projectPath: string, 
      frameworks: string[],
      profile: 'minimal' | 'standard' | 'comprehensive' = 'standard'
    ): Promise<ComplianceReport> {
      // Run security scans first if scanner is available
      let findings: Finding[] = [];
      let scanTimeMs = 0;
      let tokenUsage = 0;
    
      if (this.projectScanner) {
        console.error('Running security scans for compliance validation...');
        
        const scanRequest: ScanRequest = {
          type: 'project',
          target: projectPath,
          profile: profile === 'minimal' ? 'quick' : profile === 'comprehensive' ? 'thorough' : 'standard',
          options: {
            parallel: true,
          },
        };
    
        const scanResult = await this.projectScanner.scan(scanRequest);
        findings = scanResult.findings;
        scanTimeMs = scanResult.scanTimeMs;
        tokenUsage = scanResult.tokenUsage;
        
        console.error(`Found ${findings.length} findings to map to compliance frameworks`);
      } else {
        console.warn('No project scanner available, using empty findings list');
      }
    
      // Map findings to each framework
      const frameworkResults: FrameworkResult[] = [];
      
      for (const framework of frameworks) {
        const frameworkType = framework.toUpperCase() as 'OWASP' | 'CIS' | 'NIST' | 'ISO27001';
        
        if (['OWASP', 'CIS', 'NIST', 'ISO27001'].includes(frameworkType)) {
          const result = this.mapper.mapFindingsToFramework(findings, frameworkType);
          frameworkResults.push(result);
        } else {
          console.warn(`Unknown compliance framework: ${framework}`);
        }
      }
    
      // Calculate summary
      const criticalFindings = findings.filter(f => f.severity === 'critical').length;
      const highFindings = findings.filter(f => f.severity === 'high').length;
      
      const overallCompliance = frameworkResults.length > 0
        ? Math.round(frameworkResults.reduce((sum, r) => sum + r.coverage, 0) / frameworkResults.length)
        : 0;
    
      const recommendations = this.generateRecommendations(frameworkResults, findings);
    
      const report: ComplianceReport = {
        timestamp: new Date().toISOString(),
        projectPath,
        profile,
        frameworks: frameworkResults,
        summary: {
          overallCompliance,
          totalFindings: findings.length,
          criticalFindings,
          highFindings,
          recommendations,
        },
        scanResults: {
          findings,
          scanTimeMs,
          tokenUsage,
        },
      };
    
      // Save report to file
      await this.saveReport(report);
    
      return report;
    }
  • Maps security scan findings to compliance framework controls by matching finding types, severities, and keywords; determines control status (passed/failed/partial) and generates coverage metrics.
    public mapFindingsToFramework(
      findings: Finding[],
      framework: 'OWASP' | 'CIS' | 'NIST' | 'ISO27001'
    ): FrameworkResult {
      let controls: Map<string, ComplianceControl>;
      let frameworkName: string;
      let version: string;
    
      switch (framework) {
        case 'OWASP':
          controls = this.owaspControls;
          frameworkName = 'OWASP Top 10';
          version = '2021';
          break;
        case 'CIS':
          controls = this.cisControls;
          frameworkName = 'CIS Controls';
          version = 'v8';
          break;
        case 'NIST':
          controls = this.nistControls;
          frameworkName = 'NIST Cybersecurity Framework';
          version = '1.1';
          break;
        case 'ISO27001':
          controls = this.isoControls;
          frameworkName = 'ISO 27001';
          version = '2022';
          break;
      }
    
      const controlResults: ControlResult[] = [];
      let passed = 0;
      let failed = 0;
      let partial = 0;
      let notApplicable = 0;
    
      for (const [controlId, control] of controls) {
        const relevantFindings = this.findRelevantFindings(findings, control);
        
        let status: 'passed' | 'failed' | 'partial' | 'not_applicable';
        
        if (relevantFindings.length === 0) {
          // No findings related to this control
          status = 'passed';
          passed++;
        } else {
          const criticalFindings = relevantFindings.filter(f => f.severity === 'critical');
          const highFindings = relevantFindings.filter(f => f.severity === 'high');
          
          if (criticalFindings.length > 0) {
            status = 'failed';
            failed++;
          } else if (highFindings.length > 0) {
            status = 'partial';
            partial++;
          } else {
            status = 'partial';
            partial++;
          }
        }
    
        controlResults.push({
          id: controlId,
          title: control.title,
          status,
          findings: relevantFindings,
          evidence: this.generateEvidence(relevantFindings),
          recommendation: this.generateRecommendation(control, relevantFindings),
        });
      }
    
      const totalControls = controls.size;
      const coverage = Math.round(((passed + partial) / totalControls) * 100);
    
      return {
        framework: frameworkName,
        version,
        totalControls,
        passed,
        failed,
        partial,
        notApplicable,
        coverage,
        controls: controlResults,
      };
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'validates' implies a read-only assessment, the description doesn't specify whether this tool requires special permissions, whether it modifies anything, what the validation process entails, or what happens with the results. For a compliance validation tool with zero annotation coverage, this is insufficient.

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 that states the core functionality without unnecessary words. It's appropriately sized for a tool with three parameters and gets straight to the point with zero wasted content.

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?

Given the complexity of compliance validation and the absence of both annotations and an output schema, the description is incomplete. It doesn't explain what the validation produces (e.g., a report, pass/fail status, detailed findings), how results are structured, or what behavioral constraints apply. For a tool that likely produces important compliance assessment results, this leaves significant gaps.

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?

The schema description coverage is 100%, so all parameters are well-documented in the schema itself. The description doesn't add any meaningful parameter semantics beyond what's already in the schema descriptions (e.g., explaining what 'frameworks' represent or how 'path' is interpreted). This meets the baseline expectation when schema coverage is complete.

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 tool's purpose with a specific verb ('validates') and resource ('project against compliance frameworks'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'scan_project' or 'pentest_application', which might have overlapping security/compliance functions.

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. With sibling tools like 'scan_project' and 'pentest_application' that might serve related security purposes, there's no indication of when validation against compliance frameworks is preferred over other scanning or testing approaches.

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