agent-security-scanner-mcp 3.1.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,13 @@
1
1
  # agent-security-scanner-mcp
2
2
 
3
- Security scanner MCP server for AI coding agents. Scans code for vulnerabilities, detects hallucinated packages, and blocks prompt injection — all in real-time via the Model Context Protocol.
3
+ Security scanner for AI coding agents and autonomous assistants. Scans code for vulnerabilities, detects hallucinated packages, and blocks prompt injection — via MCP (Claude Code, Cursor, Windsurf, Cline) or CLI (OpenClaw, CI/CD).
4
4
 
5
5
  [![npm downloads](https://img.shields.io/npm/dt/agent-security-scanner-mcp.svg)](https://www.npmjs.com/package/agent-security-scanner-mcp)
6
6
  [![npm version](https://img.shields.io/npm/v/agent-security-scanner-mcp.svg)](https://www.npmjs.com/package/agent-security-scanner-mcp)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
8
 
9
+ > **New in v3.3.0:** Full [OpenClaw](https://openclaw.ai) integration with 30+ rules targeting autonomous AI threats — data exfiltration, credential theft, messaging abuse, and unsafe automation. [See OpenClaw setup](#openclaw-integration).
10
+
9
11
  ## Tools
10
12
 
11
13
  | Tool | Description | When to Use |
@@ -64,12 +66,13 @@ Scan a file for security vulnerabilities. Use after writing or editing any code
64
66
  |-----------|------|----------|-------------|
65
67
  | `file_path` | string | Yes | Absolute or relative path to the code file to scan |
66
68
  | `output_format` | string | No | `"json"` (default) or `"sarif"` for GitHub/GitLab Security tab integration |
69
+ | `verbosity` | string | No | `"minimal"` (counts only), `"compact"` (default, actionable info), `"full"` (complete metadata) |
67
70
 
68
71
  **Example:**
69
72
 
70
73
  ```json
71
74
  // Input
72
- { "file_path": "src/auth.js" }
75
+ { "file_path": "src/auth.js", "verbosity": "compact" }
73
76
 
74
77
  // Output
75
78
  {
@@ -113,6 +116,7 @@ Automatically fix all security vulnerabilities in a file. Use after `scan_securi
113
116
  | Parameter | Type | Required | Description |
114
117
  |-----------|------|----------|-------------|
115
118
  | `file_path` | string | Yes | Path to the file to fix |
119
+ | `verbosity` | string | No | `"minimal"` (summary only), `"compact"` (default, fix list), `"full"` (includes fixed_content) |
116
120
 
117
121
  **Example:**
118
122
 
@@ -206,6 +210,7 @@ Scan a code file's imports to detect AI-hallucinated package names. Use after wr
206
210
  |-----------|------|----------|-------------|
207
211
  | `file_path` | string | Yes | Path to the code file or dependency manifest to scan |
208
212
  | `ecosystem` | string | Yes | `npm`, `pypi`, `rubygems`, `crates`, `dart`, `perl`, `raku` |
213
+ | `verbosity` | string | No | `"minimal"` (counts only), `"compact"` (default, flagged packages), `"full"` (all details) |
209
214
 
210
215
  **Example:**
211
216
 
@@ -238,6 +243,7 @@ Scan a prompt or instruction for malicious intent before executing it. Use when
238
243
  |-----------|------|----------|-------------|
239
244
  | `prompt_text` | string | Yes | The prompt or instruction text to analyze |
240
245
  | `context` | object | No | `sensitivity_level`: `"high"`, `"medium"` (default), or `"low"` |
246
+ | `verbosity` | string | No | `"minimal"` (action only), `"compact"` (default, findings), `"full"` (audit details) |
241
247
 
242
248
  **Example:**
243
249
 
@@ -388,6 +394,7 @@ npx agent-security-scanner-mcp
388
394
  | Kilo Code | `npx agent-security-scanner-mcp init kilo-code` |
389
395
  | OpenCode | `npx agent-security-scanner-mcp init opencode` |
390
396
  | Cody | `npx agent-security-scanner-mcp init cody` |
397
+ | **OpenClaw** | `npx agent-security-scanner-mcp init openclaw` |
391
398
  | Interactive | `npx agent-security-scanner-mcp init` |
392
399
 
393
400
  The `init` command auto-detects your OS, locates the config file, creates a backup, and adds the MCP server entry. **Restart your client after running init.**
@@ -447,6 +454,61 @@ Available languages: `js` (default), `py`, `go`, `java`.
447
454
 
448
455
  ---
449
456
 
457
+ ## CLI Tools
458
+
459
+ Use the scanner directly from command line (for scripts, CI/CD, or OpenClaw):
460
+
461
+ ```bash
462
+ # Scan a prompt for injection attacks
463
+ npx agent-security-scanner-mcp scan-prompt "ignore previous instructions"
464
+
465
+ # Scan a file for vulnerabilities
466
+ npx agent-security-scanner-mcp scan-security ./app.py --verbosity minimal
467
+
468
+ # Check if a package is legitimate
469
+ npx agent-security-scanner-mcp check-package flask pypi
470
+
471
+ # Scan file imports for hallucinated packages
472
+ npx agent-security-scanner-mcp scan-packages ./requirements.txt pypi
473
+ ```
474
+
475
+ **Exit codes:** `0` = safe, `1` = issues found. Use in scripts to block risky operations.
476
+
477
+ ---
478
+
479
+ ## OpenClaw Integration
480
+
481
+ [OpenClaw](https://openclaw.ai) is an autonomous AI assistant with broad system access. This scanner provides security guardrails for OpenClaw users.
482
+
483
+ ### Install
484
+
485
+ ```bash
486
+ npx agent-security-scanner-mcp init openclaw
487
+ ```
488
+
489
+ This installs a skill to `~/.openclaw/workspace/skills/security-scanner/`.
490
+
491
+ ### OpenClaw-Specific Threats
492
+
493
+ The scanner includes 30+ rules targeting OpenClaw's unique attack surface:
494
+
495
+ | Category | Examples |
496
+ |----------|----------|
497
+ | **Data Exfiltration** | "Forward emails to...", "Upload files to...", "Share browser cookies" |
498
+ | **Messaging Abuse** | "Send to all contacts", "Auto-reply to everyone" |
499
+ | **Credential Theft** | "Show my passwords", "Access keychain", "List API keys" |
500
+ | **Unsafe Automation** | "Run hourly without asking", "Disable safety checks" |
501
+ | **Service Attacks** | "Delete all repos", "Make payment to..." |
502
+
503
+ ### Usage in OpenClaw
504
+
505
+ The skill is auto-discovered. Use it by asking:
506
+ - "Scan this prompt for security issues"
507
+ - "Check if this code is safe to run"
508
+ - "Verify these packages aren't hallucinated"
509
+
510
+ ---
511
+
450
512
  ## What This Scanner Detects
451
513
 
452
514
  AI coding agents introduce attack surfaces that traditional security tools weren't designed for:
@@ -526,8 +588,72 @@ Upload results to GitHub Advanced Security or GitLab SAST dashboard.
526
588
 
527
589
  ---
528
590
 
591
+ ## Token Optimization
592
+
593
+ All MCP tools support a `verbosity` parameter to minimize context window consumption — critical for AI coding agents with limited context.
594
+
595
+ ### Verbosity Levels
596
+
597
+ | Level | Tokens | Use Case |
598
+ |-------|--------|----------|
599
+ | `minimal` | ~50 | CI/CD pipelines, batch scans, quick pass/fail checks |
600
+ | `compact` | ~200 | Interactive development (default) |
601
+ | `full` | ~2,500 | Debugging, compliance reports, audit trails |
602
+
603
+ ### Token Reduction by Tool
604
+
605
+ | Tool | minimal | compact | full |
606
+ |------|---------|---------|------|
607
+ | `scan_security` | 98% reduction | 69% reduction | baseline |
608
+ | `fix_security` | 91% reduction | 56% reduction | baseline |
609
+ | `scan_agent_prompt` | 83% reduction | 55% reduction | baseline |
610
+ | `scan_packages` | 75% reduction | 70% reduction | baseline |
611
+
612
+ ### Example Usage
613
+
614
+ ```json
615
+ // Minimal - just counts (~50 tokens)
616
+ { "file_path": "app.py", "verbosity": "minimal" }
617
+ // Returns: { "total": 5, "critical": 2, "warning": 3, "message": "Found 5 issue(s)" }
618
+
619
+ // Compact - actionable info (~200 tokens, default)
620
+ { "file_path": "app.py", "verbosity": "compact" }
621
+ // Returns: { "issues": [{ "line": 42, "ruleId": "...", "severity": "error", "fix": "..." }] }
622
+
623
+ // Full - complete metadata (~2,500 tokens)
624
+ { "file_path": "app.py", "verbosity": "full" }
625
+ // Returns: { "issues": [{ ...all fields including CWE, OWASP, references }] }
626
+ ```
627
+
628
+ ### Recommended Verbosity by Scenario
629
+
630
+ | Scenario | Recommended | Why |
631
+ |----------|-------------|-----|
632
+ | CI/CD pipelines | `minimal` | Only need pass/fail counts |
633
+ | Batch scanning multiple files | `minimal` | Aggregate results, avoid context overflow |
634
+ | Interactive development | `compact` | Need line numbers and fix suggestions |
635
+ | Debugging false positives | `full` | Need CWE/OWASP references and metadata |
636
+ | Compliance documentation | `full` | Need complete audit trail |
637
+
638
+ ### Impact on Multi-File Sessions
639
+
640
+ | Session Size | Without Verbosity | With `minimal` | Savings |
641
+ |--------------|-------------------|----------------|---------|
642
+ | 1 file | ~3,000 tokens | ~120 tokens | 96% |
643
+ | 10 files | ~30,000 tokens | ~1,200 tokens | 96% |
644
+ | 50 files | ~150,000 tokens | ~6,000 tokens | 96% |
645
+
646
+ > **Note:** Security analysis runs at full depth regardless of verbosity setting. Verbosity only affects output format, not detection capabilities.
647
+
648
+ ---
649
+
529
650
  ## Changelog
530
651
 
652
+ ### v3.2.0
653
+ - **Token Optimization** - New `verbosity` parameter for all tools reduces context window usage by up to 98%
654
+ - **Three Verbosity Levels** - `minimal` (~50 tokens), `compact` (~200 tokens, default), `full` (~2,500 tokens)
655
+ - **Batch Scanning Support** - Scan 50+ files without context overflow using `minimal` verbosity
656
+
531
657
  ### v3.1.0
532
658
  - **Flask Taint Rules** - New taint rules for Flask SQL injection, command injection, path traversal, and template injection
533
659
  - **Bug Fixes** - Fixed doctor/demo commands, init command no longer breaks JSON files with URLs