agentleFS
sinewaveaisinewaveai/agent-security-scanner-mcp/CLAUDE.md

agent-security-scanner-mcp

CLAUDE.md122 starsChanged 10 months agoMITView on GitHub

This is an MCP (Model Context Protocol) server that provides security scanning tools for AI coding agents. It also serves as an OpenClaw plugin via the SKILL.md format.

  • Installs packages

The file

We split this CLAUDE.md into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Add rules to the appropriate YAML file in rules/ following this format:

    line 150
  2. Very specific:

    All MCP tools support a verbosity parameter:

    line 165

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Build and Development Commands

# Install dependencies
npm install

# Run all tests (28 test files, 420+ tests, ~4.5 min)
npm test

# Run specific test file
npx vitest run tests/scan-security.test.js

# Run Python tests
python -m pytest test_ast_engine.py -v
python -m pytest src/test_semgrep_rules.py -v

# Run analyzer on a file
python3 analyzer.py <file_path>

# Run CLI commands
node index.js --help
node index.js scan-security <file>
node index.js scan-prompt <text>
node index.js scan-skill <path>
node index.js audit
node index.js doctor

Architecture Overview

This is an MCP (Model Context Protocol) server that provides security scanning tools for AI coding agents. It also serves as an OpenClaw plugin via the SKILL.md format.

Directory Structure

agent-security-scanner-mcp/
├── index.js                    # Entry point: MCP server, tool registration, CLI routing
├── package.json                # npm package manifest (v4.0.0, ESM)
├── vitest.config.js            # Test config (60s timeout, sequential)
├── openclaw.plugin.json        # OpenClaw plugin metadata
├── server.json                 # MCP server manifest
│
├── src/
│   ├── utils.js                # Shared: detectLanguage, runAnalyzer, extractImports, toSarif
│   ├── fix-patterns.js         # 165 security fix templates
│   ├── config.js               # .scannerrc config loading
│   ├── context.js              # Context-aware filtering, isTestFile
│   ├── daemon-client.js        # Python daemon lifecycle (DaemonClient)
│   ├── dedup.js                # Cross-engine deduplication
│   ├── history.js              # Scan history tracking
│   ├── typosquat.js            # Typosquatting detection
│   ├── plugin-config.js        # Plugin configuration loader
│   ├── plugin-health.js        # Plugin health endpoint
│   ├── tools/
│   │   ├── scan-security.js    # scan_security — file vulnerability scanning
│   │   ├── fix-security.js     # fix_security — auto-fix generation
│   │   ├── check-package.js    # check_package — hallucination detection
│   │   ├── scan-packages.js    # scan_packages — bulk import scanning
│   │   ├── scan-prompt.js      # scan_agent_prompt — prompt injection detection
│   │   ├── scan-action.js      # scan_agent_action — pre-execution safety
│   │   ├── scan-project.js     # scan_project — directory scanning
│   │   ├── scan-diff.js        # scan_git_diff — git diff scanning
│   │   ├── scan-mcp.js         # scan_mcp_server — MCP server audit
│   │   ├── scan-skill.js       # scan_skill — OpenClaw skill scanning
│   │   ├── import-resolver.js  # Import graph resolution
│   │   └── project-context.js  # Project context detection
│   └── cli/
│       ├── init.js             # init — MCP config setup (9 clients incl. OpenClaw)
│       ├── doctor.js           # doctor — environment diagnostics
│       ├── demo.js             # demo — generate vulnerable files
│       ├── init-hooks.js       # init-hooks — git hook installation
│       ├── report.js           # report — HTML/JSON security reports
│       ├── audit.js            # audit — OpenClaw config audit
│       └── harden.js           # harden — auto-hardening
│
├── analyzer.py                 # Python analysis engine (AST + taint + regex)
├── ast_parser.py               # tree-sitter AST wrapper (11 languages)
├── generic_ast.py              # Generic AST converter
├── pattern_matcher.py          # Semgrep-style pattern matching
├── regex_fallback.py           # Line-based regex scanner
├── semgrep_loader.py           # YAML rule loader
├── taint_analyzer.py           # Dataflow/taint analysis
├── cross_file_analyzer.py      # Cross-file taint tracking
├── daemon.py                   # JSONL daemon wrapping analyzer
│
├── rules/                      # 1700+ YAML security rules
├── packages/                   # Bloom filters for 4.3M+ packages
├── skills/                     # OpenClaw and Claude Code skills
├── tests/                      # Vitest test suite (28 files)
├── benchmarks/                 # Accuracy benchmarks
├── templates/                  # CI/CD templates
└── scripts/                    # Build/install scripts

MCP Tools (13 total)

ToolFileDescription
scan_securitysrc/tools/scan-security.jsScan code for vulnerabilities
fix_securitysrc/tools/fix-security.jsAuto-fix vulnerabilities
check_packagesrc/tools/check-package.jsVerify single package
scan_packagessrc/tools/scan-packages.jsCheck all imports in file
scan_agent_promptsrc/tools/scan-prompt.jsDetect prompt injection
scan_agent_actionsrc/tools/scan-action.jsPre-execution safety check
scan_projectsrc/tools/scan-project.jsDirectory scanning with grading
scan_git_diffsrc/tools/scan-diff.jsGit diff scanning
scan_mcp_serversrc/tools/scan-mcp.jsMCP server audit
scan_skillsrc/tools/scan-skill.jsOpenClaw skill scanning
scanner_healthsrc/plugin-health.jsPlugin health check
get_compliance_controlssrc/tools/compliance-controls.jsLook up compliance controls (AIUC-1, SOC2, GDPR)
evaluate_compliancesrc/tools/evaluate-compliance.jsEvaluate project against compliance frameworks

CLI Commands

CommandFileDescription
init <client>src/cli/init.jsSetup MCP for AI client
doctorsrc/cli/doctor.jsCheck environment
demo --lang <lang>src/cli/demo.jsGenerate demo file
init-hookssrc/cli/init-hooks.jsInstall git hooks
report <dir>src/cli/report.jsGenerate security report
scan-skill <path>src/tools/scan-skill.jsScan OpenClaw skill
auditsrc/cli/audit.jsAudit OpenClaw config
hardensrc/cli/harden.jsAuto-harden config

Data Flow

  1. MCP client sends tool call (e.g., scan_security)
  2. index.js routes to tool handler in src/tools/
  3. Tool calls Python via runAnalyzerAsync() → daemon (JSONL over stdin/stdout) → sync fallback
  4. analyzer.py uses AST + taint + regex analysis
  5. Results enhanced with fix suggestions, context filtering, framework adjustments
  6. JSON/SARIF response returned to client

Daemon Architecture

The Python daemon (daemon.py) provides persistent analysis with LRU caching:

  • DaemonClient (src/daemon-client.js) manages lifecycle
  • Communication: JSONL over stdin/stdout
  • Actions: analyze, cross_file_analyze, health, shutdown
  • Pre-warmed on MCP server startup (set SCANNER_PREWARM=0 to disable)
  • Falls back to execFileSync if daemon is unavailable

Adding New Rules

Add rules to the appropriate YAML file in rules/ following this format:

- id: language.category.rule-name
  languages: [language]
  severity: ERROR|WARNING|INFO
  message: "Description of the vulnerability"
  patterns:
    - "regex_pattern_1"
  metadata:
    cwe: "CWE-XXX"
    owasp: "Category"

Context Optimization

All MCP tools support a verbosity parameter:

LevelTokensUse Case
minimal~50Quick checks, CI pipelines
compact~200Normal development (default)
full~2000Debugging, compliance reports

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.