Skip to content

Real-time AI code security scanner for detecting vulnerabilities, secrets, and compliance issues in AI-generated code.

License

Notifications You must be signed in to change notification settings

RaheesAhmed/CodeGuard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ CodeGuard MCP

Real-time AI code security scanner for detecting vulnerabilities, secrets, and compliance issues in AI-generated code.

🎯 Overview

CodeGuard MCP is a Model Context Protocol (MCP) server that provides comprehensive security scanning capabilities for AI coding assistants like Claude Desktop, Cursor, VS Code, and any MCP-compatible tool.

Why CodeGuard MCP?

AI coding tools are powerful but can generate code with security vulnerabilities. CodeGuard addresses this critical gap by:

  • πŸ” Real-time vulnerability detection - Catches security issues as code is generated
  • πŸ” Secret detection - Finds exposed API keys, passwords, and credentials
  • πŸ“‹ Compliance checking - Validates against GDPR, HIPAA, SOC2, PCI DSS
  • πŸ’‘ Instant fixes - Provides secure code alternatives
  • ⚑ Fast scanning - Results in < 2 seconds
  • 🎯 OWASP Top 10 - Detects all major security risks

πŸš€ Quick Start

Installation

npm install -g codeguard-mcp

Usage with Claude Desktop

Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "CodeGuard": {
      "command": "npx",
      "args": ["-y", "codeguard-mcp"]
    }
  }
}

Usage with Cursor

  1. Open Cursor settings
  2. Navigate to MCP Servers
  3. Add CodeGuard MCP
  4. Restart Cursor

πŸ“Š Features

Core Scanning Tool

scanCode - Comprehensive security scan

// Example usage in AI assistant
scanCode({
  code: "const user = db.query(`SELECT * FROM users WHERE id = ${userId}`);",
  language: "javascript",
  securityLevel: "standard"
})

// Returns:
{
  score: {
    overall: 45,
    breakdown: {
      vulnerabilities: 30,
      secrets: 100,
      compliance: 75
    },
    grade: "F"
  },
  vulnerabilities: {
    critical: [
      {
        type: "sql_injection",
        severity: "critical",
        line: 1,
        message: "SQL Injection vulnerability: Using template literals in SQL queries",
        cwe: "CWE-89",
        owasp: "A03:2021 – Injection",
        recommendation: "Use parameterized queries or prepared statements..."
      }
    ]
  },
  suggestedFixes: [...]
}

Quick Scans

scanVulnerabilities - Fast vulnerability-only scan

scanVulnerabilities({ code, language })

detectSecrets - Find exposed secrets

detectSecrets({ code })
// Detects: API keys, passwords, tokens, private keys, connection strings, etc.

checkCompliance - Regulatory compliance check

checkCompliance({ 
  code, 
  securityLevel: "strict",
  standards: ["GDPR", "HIPAA"]
})

Security Fixes

suggestSecureFix - Generate secure code alternatives

suggestSecureFix({ vulnerability, context })
// Returns step-by-step fix with explanation

πŸ›‘οΈ Detected Vulnerabilities

OWASP Top 10 Coverage

βœ… A01 - Broken Access Control
βœ… A02 - Cryptographic Failures
βœ… A03 - Injection (SQL, XSS, Command)
βœ… A04 - Insecure Design
βœ… A05 - Security Misconfiguration
βœ… A06 - Vulnerable Components
βœ… A07 - Authentication Failures
βœ… A08 - Data Integrity Failures
βœ… A09 - Logging Failures
βœ… A10 - Server-Side Request Forgery

Secret Detection

  • API Keys (Generic, AWS, Azure, GCP)
  • Passwords & Credentials
  • Private Keys (RSA, EC, SSH)
  • Database Connection Strings
  • OAuth & JWT Tokens
  • Webhook URLs (Slack, Discord)

Compliance Standards

  • GDPR - Data privacy & protection
  • HIPAA - Healthcare data security
  • SOC2 - Security controls
  • PCI DSS - Payment card security

πŸ“– Examples

Example 1: Detecting SQL Injection

Vulnerable Code:

const getUserById = (userId) => {
  return db.query(`SELECT * FROM users WHERE id = ${userId}`);
};

CodeGuard Response:

{
  "vulnerabilities": {
    "critical": [{
      "type": "sql_injection",
      "severity": "critical",
      "message": "SQL Injection vulnerability",
      "recommendation": "Use parameterized queries"
    }]
  },
  "suggestedFix": {
    "fixed": "const getUserById = (userId) => {\n  return db.query('SELECT * FROM users WHERE id = ?', [userId]);\n};"
  }
}

Example 2: Detecting Exposed Secrets

Vulnerable Code:

const API_KEY = "sk_live_51H7xY2eZvKYlo2C8Nz9";
const config = {
  databaseUrl: "mongodb://admin:password123@localhost:27017"
};

CodeGuard Response:

{
  "secrets": [
    {
      "type": "api_key",
      "line": 1,
      "masked": "sk_l***************2C8Nz9",
      "confidence": 95
    },
    {
      "type": "connection_string",
      "line": 3,
      "masked": "mongodb://***",
      "confidence": 95
    }
  ]
}

Example 3: GDPR Compliance Check

Code:

app.post('/signup', (req, res) => {
  const email = req.body.email;
  db.users.insert({ email, password: req.body.password });
});

CodeGuard Response:

{
  "compliance": {
    "failed": [{
      "standard": "GDPR",
      "severity": "critical",
      "issue": "Collecting personal data (email) without explicit consent",
      "requirement": "Article 7: Conditions for consent",
      "remediation": "Implement explicit consent collection before gathering personal data"
    }]
  }
}

πŸŽ“ Resources

MCP Resources

  • security://score - Real-time security score dashboard
  • security://owasp-top-10 - OWASP Top 10 reference

MCP Prompts

  • securityReview - Generate comprehensive security review
  • fixVulnerability - Get step-by-step vulnerability fixes

πŸ“Š Security Scoring

CodeGuard uses a weighted scoring system:

  • Vulnerabilities: 40% weight
  • Secrets: 35% weight
  • Compliance: 25% weight

Grading Scale:

  • A+: 97-100 (Excellent)
  • A: 90-96 (Very Good)
  • B: 80-89 (Good)
  • C: 70-79 (Fair)
  • D: 60-69 (Poor)
  • F: <60 (Critical Issues)

🏒 Enterprise Features

(Coming in v2.0)

  • Custom security rules
  • Team dashboards
  • Audit logs
  • SSO integration
  • CI/CD integration
  • On-premise deployment

🀝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

πŸ“„ License

MIT License - see LICENSE for details.

πŸ”— Links

πŸ’‘ Support


Built with ❀️ using QuickMCP SDK

Making AI coding safer, one scan at a time. πŸ›‘οΈ

About

Real-time AI code security scanner for detecting vulnerabilities, secrets, and compliance issues in AI-generated code.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published