agent-security-scanner-mcp 2.0.4 → 2.0.5

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,5 +1,11 @@
1
1
  # agent-security-scanner-mcp
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/agent-security-scanner-mcp.svg)](https://www.npmjs.com/package/agent-security-scanner-mcp)
4
+ [![npm downloads](https://img.shields.io/npm/dm/agent-security-scanner-mcp.svg)](https://www.npmjs.com/package/agent-security-scanner-mcp)
5
+ [![npm total downloads](https://img.shields.io/npm/dt/agent-security-scanner-mcp.svg)](https://www.npmjs.com/package/agent-security-scanner-mcp)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+ [![GitHub stars](https://img.shields.io/github/stars/sinewaveai/agent-security-scanner-mcp.svg)](https://github.com/sinewaveai/agent-security-scanner-mcp/stargazers)
8
+
3
9
  A powerful MCP (Model Context Protocol) server for real-time security vulnerability scanning. Integrates with Claude Desktop, Claude Code, OpenCode.ai, Kilo Code, and any MCP-compatible client to automatically detect and fix security issues as you code.
4
10
 
5
11
  AI coding agents like **Claude Code**, **Cursor**, **Windsurf**, **Cline**, **Copilot**, and **Devin** are transforming software development. But they introduce attack surfaces that traditional security tools weren't designed to handle:
@@ -14,22 +20,35 @@ AI coding agents like **Claude Code**, **Cursor**, **Windsurf**, **Cline**, **Co
14
20
 
15
21
  **359 Semgrep-aligned security rules | 120 auto-fix templates | 6 ecosystems indexed | AI Agent prompt security**
16
22
 
17
- ## What's New in v2.0.2
23
+ ## Installation
18
24
 
19
- - **Prompt injection detection overhaul** - Detection rate improved from 33% to 80%+
20
- - **Code block scanning** - Detects attacks hidden inside markdown code blocks
21
- - **Base64 decode-and-rescan** - Runtime decoding of encoded payloads
22
- - **Security fix** - Command injection vulnerability patched (execFileSync)
23
- - **Test suite** - 51 vitest tests with GitHub Actions CI
24
- - **Bug fixes** - Package hallucination detection now correctly uses bloom filters
25
+ ### Default Package (Lightweight - 2.7 MB)
25
26
 
26
- ## What's New in v2.0.0
27
+ ```bash
28
+ npm install -g agent-security-scanner-mcp
29
+ ```
27
30
 
28
- - **AST-based analysis** - tree-sitter powered parsing for 12 languages with higher accuracy
29
- - **Taint analysis** - Track data flow from sources (user input) to sinks (dangerous functions)
30
- - **Graceful fallback** - Works out-of-the-box with regex; enhanced detection when tree-sitter installed
31
- - **Metavariable patterns** - Semgrep-style `$VAR` patterns for structural matching
32
- - **Doctor command upgrade** - Now checks for AST engine availability
31
+ Includes hallucination detection for: **PyPI, RubyGems, crates.io, pub.dev, CPAN, raku.land** (1M+ packages)
32
+
33
+ ### Full Package (With npm - 8.7 MB)
34
+
35
+ If you need **npm/JavaScript hallucination detection** (3.3M packages):
36
+
37
+ ```bash
38
+ npm install -g agent-security-scanner-mcp-full
39
+ ```
40
+
41
+ Or run directly with npx:
42
+
43
+ ```bash
44
+ npx agent-security-scanner-mcp
45
+ ```
46
+
47
+ ### Prerequisites
48
+
49
+ - **Node.js >= 18.0.0** (required)
50
+ - **Python 3.x** (required for the analyzer engine)
51
+ - **PyYAML** (`pip install pyyaml`) — required for rule loading
33
52
 
34
53
  ### Enhanced Detection with tree-sitter (Optional)
35
54
 
@@ -44,6 +63,31 @@ The scanner works without tree-sitter using regex-based detection, but AST analy
44
63
  - Taint tracking across function boundaries
45
64
  - Language-aware pattern matching
46
65
 
66
+ ---
67
+
68
+ ## What's New in v2.0.5
69
+
70
+ - **Claude Code per-project fix** - `init claude-code` now uses `claude mcp add` CLI for reliable per-project configuration
71
+ - **Doctor command upgrade** - Now correctly checks Claude Code config via `claude mcp list` instead of file-based check
72
+ - **Documentation update** - README clarifies Claude Code's per-project MCP storage (`~/.claude.json` vs `~/.claude/settings.json`)
73
+
74
+ ## What's New in v2.0.2
75
+
76
+ - **Prompt injection detection overhaul** - Detection rate improved from 33% to 80%+
77
+ - **Code block scanning** - Detects attacks hidden inside markdown code blocks
78
+ - **Base64 decode-and-rescan** - Runtime decoding of encoded payloads
79
+ - **Security fix** - Command injection vulnerability patched (execFileSync)
80
+ - **Test suite** - 51 vitest tests with GitHub Actions CI
81
+ - **Bug fixes** - Package hallucination detection now correctly uses bloom filters
82
+
83
+ ## What's New in v2.0.0
84
+
85
+ - **AST-based analysis** - tree-sitter powered parsing for 12 languages with higher accuracy
86
+ - **Taint analysis** - Track data flow from sources (user input) to sinks (dangerous functions)
87
+ - **Graceful fallback** - Works out-of-the-box with regex; enhanced detection when tree-sitter installed
88
+ - **Metavariable patterns** - Semgrep-style `$VAR` patterns for structural matching
89
+ - **Doctor command upgrade** - Now checks for AST engine availability
90
+
47
91
  ## What's New in v1.5.0
48
92
 
49
93
  - **92% smaller package** - Only 2.7 MB (down from 84 MB)
@@ -76,37 +120,6 @@ The scanner works without tree-sitter using regex-based detection, but AST analy
76
120
  - **CWE & OWASP mapped** - Every rule includes CWE and OWASP references
77
121
  - **Hallucination detection** - Detect AI-invented package names across 7 ecosystems via bloom filters and text lists
78
122
 
79
- ## Installation
80
-
81
- ### Default Package (Lightweight - 2.7 MB)
82
-
83
- ```bash
84
- npm install -g agent-security-scanner-mcp
85
- ```
86
-
87
- Includes hallucination detection for: **PyPI, RubyGems, crates.io, pub.dev, CPAN, raku.land** (1M+ packages)
88
-
89
- ### Full Package (With npm - 8.7 MB)
90
-
91
- If you need **npm/JavaScript hallucination detection** (3.3M packages):
92
-
93
- ```bash
94
- npm install -g agent-security-scanner-mcp-full
95
- ```
96
-
97
- Or run directly with npx:
98
-
99
- ```bash
100
- npx agent-security-scanner-mcp
101
- ```
102
-
103
- ## Prerequisites
104
-
105
- - **Node.js >= 18.0.0** (required)
106
- - **Python 3.x** (required for the analyzer engine)
107
- - **PyYAML** (`pip install pyyaml`) — required for rule loading
108
- - **tree-sitter** (optional, for enhanced AST-based detection): `pip install tree-sitter tree-sitter-python tree-sitter-javascript`
109
-
110
123
  ## Works With All Major AI Coding Tools
111
124
 
112
125
  | Tool | Integration | Status |
@@ -139,12 +152,14 @@ npx agent-security-scanner-mcp init cursor
139
152
  npx agent-security-scanner-mcp init claude-desktop
140
153
  npx agent-security-scanner-mcp init windsurf
141
154
  npx agent-security-scanner-mcp init cline
142
- npx agent-security-scanner-mcp init claude-code
155
+ npx agent-security-scanner-mcp init claude-code # Run in each project folder!
143
156
  npx agent-security-scanner-mcp init kilo-code
144
157
  npx agent-security-scanner-mcp init opencode
145
158
  npx agent-security-scanner-mcp init cody
146
159
  ```
147
160
 
161
+ > **Claude Code users:** Run `init claude-code` in **each project folder** where you want security scanning. Claude Code uses per-project MCP configuration.
162
+
148
163
  **Interactive mode** — just run `init` with no client to pick from a list:
149
164
 
150
165
  ```bash
@@ -234,7 +249,17 @@ Add to your `claude_desktop_config.json`:
234
249
 
235
250
  ### Claude Code
236
251
 
237
- Add to your MCP settings (`~/.claude/settings.json`):
252
+ **Important:** Claude Code stores MCP servers **per-project** in `~/.claude.json`, not in `~/.claude/settings.json`. Use the CLI to configure:
253
+
254
+ ```bash
255
+ # Run this in EACH project folder where you want security scanning:
256
+ claude mcp add security-scanner -- npx -y agent-security-scanner-mcp
257
+
258
+ # Verify it's configured:
259
+ claude mcp list
260
+ ```
261
+
262
+ **Global configuration** (applies to new projects only) — add to `~/.claude/settings.json`:
238
263
 
239
264
  ```json
240
265
  {
@@ -247,6 +272,8 @@ Add to your MCP settings (`~/.claude/settings.json`):
247
272
  }
248
273
  ```
249
274
 
275
+ > **Note:** Existing projects won't automatically inherit from the global config. You must run `claude mcp add` in each project folder, or use the automated init command which handles this for you.
276
+
250
277
  ### OpenCode.ai
251
278
 
252
279
  Add to your `opencode.jsonc` configuration file:
package/index.js CHANGED
@@ -1724,7 +1724,10 @@ const CLIENT_CONFIGS = {
1724
1724
  name: 'Claude Code',
1725
1725
  configKey: 'mcpServers',
1726
1726
  configPath: () => join(homedir(), '.claude', 'settings.json'),
1727
- buildEntry: () => ({ ...MCP_SERVER_ENTRY })
1727
+ buildEntry: () => ({ ...MCP_SERVER_ENTRY }),
1728
+ // Claude Code stores MCP config per-project in ~/.claude.json, not in settings.json
1729
+ // Use the 'claude mcp add' CLI for reliable per-project configuration
1730
+ useCliCommand: true
1728
1731
  },
1729
1732
  'cursor': {
1730
1733
  name: 'Cursor',
@@ -1843,6 +1846,91 @@ function printInitUsage() {
1843
1846
  console.log(' npx agent-security-scanner-mcp init cline --force --name my-scanner\n');
1844
1847
  }
1845
1848
 
1849
+ // Special init handler for clients that use CLI commands (e.g., Claude Code)
1850
+ async function runCliInit(client, flags) {
1851
+ const serverName = flags.name;
1852
+ const cwd = process.cwd();
1853
+
1854
+ console.log(`\n Client: ${client.name}`);
1855
+ console.log(` Project: ${cwd}`);
1856
+ console.log(` OS: ${platform()} (${process.arch})`);
1857
+ console.log(` Key: ${serverName}\n`);
1858
+
1859
+ // Check if claude CLI is available
1860
+ const claudeCheck = checkCommand('claude', ['--version']);
1861
+ if (!claudeCheck.ok) {
1862
+ console.log(' ERROR: Claude Code CLI not found.');
1863
+ console.log(' Please install Claude Code first: https://claude.ai/download\n');
1864
+ console.log(' Alternative: Use --path to write to ~/.claude/settings.json directly:\n');
1865
+ console.log(` npx agent-security-scanner-mcp init claude-code --path ~/.claude/settings.json\n`);
1866
+ process.exit(1);
1867
+ }
1868
+
1869
+ // Check if already configured for this project
1870
+ const listCheck = checkCommand('claude', ['mcp', 'list']);
1871
+ if (listCheck.ok && listCheck.output.includes(serverName)) {
1872
+ if (!flags.force) {
1873
+ console.log(` ${serverName} is already configured for this project.`);
1874
+ console.log(` Use --force to reconfigure.\n`);
1875
+ process.exit(0);
1876
+ }
1877
+ // Remove existing entry first if --force
1878
+ console.log(` Removing existing ${serverName} configuration...`);
1879
+ try {
1880
+ execFileSync('claude', ['mcp', 'remove', serverName], { encoding: 'utf-8', stdio: 'pipe' });
1881
+ } catch {
1882
+ // Ignore errors - might not exist
1883
+ }
1884
+ }
1885
+
1886
+ // Build the CLI command
1887
+ const cliArgs = ['mcp', 'add', serverName, '--', 'npx', '-y', 'agent-security-scanner-mcp'];
1888
+ const fullCommand = `claude ${cliArgs.join(' ')}`;
1889
+
1890
+ if (flags.dryRun) {
1891
+ console.log(` [dry-run] Would run: ${fullCommand}`);
1892
+ console.log(` [dry-run] In directory: ${cwd}`);
1893
+ console.log(`\n No changes made.\n`);
1894
+ process.exit(0);
1895
+ }
1896
+
1897
+ console.log(` Running: ${fullCommand}`);
1898
+ console.log(` In directory: ${cwd}\n`);
1899
+
1900
+ try {
1901
+ const result = execFileSync('claude', cliArgs, { encoding: 'utf-8', stdio: 'pipe', cwd });
1902
+ console.log(` ${result.trim()}\n`);
1903
+ } catch (e) {
1904
+ console.error(` ERROR: Failed to add MCP server.`);
1905
+ console.error(` ${e.message}\n`);
1906
+ console.log(' Alternative: Add manually to ~/.claude/settings.json:\n');
1907
+ console.log(` {
1908
+ "mcpServers": {
1909
+ "${serverName}": {
1910
+ "command": "npx",
1911
+ "args": ["-y", "agent-security-scanner-mcp"]
1912
+ }
1913
+ }
1914
+ }\n`);
1915
+ process.exit(1);
1916
+ }
1917
+
1918
+ // Verify it was added
1919
+ const verifyCheck = checkCommand('claude', ['mcp', 'list']);
1920
+ if (verifyCheck.ok && verifyCheck.output.includes(serverName)) {
1921
+ console.log(` ✓ Successfully configured ${serverName} for this project!\n`);
1922
+ } else {
1923
+ console.log(` ⚠ Configuration may have succeeded but verification failed.`);
1924
+ console.log(` Run 'claude mcp list' to check.\n`);
1925
+ }
1926
+
1927
+ console.log(` Next steps:`);
1928
+ console.log(` 1. Restart Claude Code in this folder`);
1929
+ console.log(` 2. Verify by asking: "What MCP tools do you have?"`);
1930
+ console.log(` 3. Test: "Scan this file for security issues"\n`);
1931
+ console.log(` Note: Run this command in each project folder where you want security scanning.\n`);
1932
+ }
1933
+
1846
1934
  async function runInit(flags) {
1847
1935
  let clientName = flags.client;
1848
1936
 
@@ -1863,6 +1951,12 @@ async function runInit(flags) {
1863
1951
  process.exit(1);
1864
1952
  }
1865
1953
 
1954
+ // Special handling for clients that use CLI commands (like Claude Code)
1955
+ if (client.useCliCommand && !flags.path) {
1956
+ await runCliInit(client, flags);
1957
+ return;
1958
+ }
1959
+
1866
1960
  const configPath = flags.path || client.configPath();
1867
1961
  const serverName = flags.name;
1868
1962
  const entry = client.buildEntry();
@@ -2067,6 +2161,53 @@ async function runDoctor(flags) {
2067
2161
  console.log('\n Client Configurations');
2068
2162
 
2069
2163
  for (const [key, client] of Object.entries(CLIENT_CONFIGS)) {
2164
+ // Special handling for Claude Code - uses per-project config via CLI
2165
+ if (client.useCliCommand) {
2166
+ const claudeCheck = checkCommand('claude', ['--version']);
2167
+ if (!claudeCheck.ok) {
2168
+ console.log(` \u2014 ${client.name.padEnd(20)} not installed (claude CLI not found)`);
2169
+ continue;
2170
+ }
2171
+
2172
+ // Check if configured for current project using claude mcp list
2173
+ const listCheck = checkCommand('claude', ['mcp', 'list']);
2174
+ if (listCheck.ok && listCheck.output) {
2175
+ const output = listCheck.output.toLowerCase();
2176
+ const hasScanner = output.includes('security-scanner') ||
2177
+ output.includes('agentic-security') ||
2178
+ output.includes('agent-security-scanner');
2179
+ if (hasScanner) {
2180
+ // Extract the actual server name from output
2181
+ let serverName = 'security-scanner';
2182
+ if (output.includes('agentic-security')) serverName = 'agentic-security';
2183
+ console.log(` \u2713 ${client.name.padEnd(20)} configured (${serverName})`);
2184
+ } else if (output.includes('no mcp servers configured')) {
2185
+ console.log(` \u2717 ${client.name.padEnd(20)} not configured for this project`);
2186
+ if (fix) {
2187
+ try {
2188
+ execFileSync('claude', ['mcp', 'add', 'security-scanner', '--', 'npx', '-y', 'agent-security-scanner-mcp'],
2189
+ { encoding: 'utf-8', stdio: 'pipe' });
2190
+ console.log(` \u2713 Fixed: added security-scanner via claude mcp add`);
2191
+ fixed++;
2192
+ } catch {
2193
+ console.log(` \u2717 Auto-fix failed. Run: npx agent-security-scanner-mcp init claude-code`);
2194
+ issues++;
2195
+ }
2196
+ } else {
2197
+ console.log(` Fix: npx agent-security-scanner-mcp init claude-code`);
2198
+ issues++;
2199
+ }
2200
+ } else {
2201
+ console.log(` \u2717 ${client.name.padEnd(20)} entry missing from project config`);
2202
+ console.log(` Fix: npx agent-security-scanner-mcp init claude-code`);
2203
+ issues++;
2204
+ }
2205
+ } else {
2206
+ console.log(` \u26a0 ${client.name.padEnd(20)} could not check config (run 'claude mcp list' manually)`);
2207
+ }
2208
+ continue;
2209
+ }
2210
+
2070
2211
  let configPath;
2071
2212
  try { configPath = client.configPath(); } catch { continue; }
2072
2213
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-security-scanner-mcp",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "mcpName": "io.github.sinewaveai/agent-security-scanner-mcp",
5
5
  "description": "Security scanner MCP server for AI coding agents. Prompt injection firewall, package hallucination detection (4.3M+ packages), 359 vulnerability rules with auto-fix. For Claude Code, Cursor, Windsurf, Cline.",
6
6
  "main": "index.js",
@@ -23630,7 +23630,6 @@ cinnog
23630
23630
  cint
23631
23631
  cio
23632
23632
  cio-api
23633
- cioqLsBmIV3xEUGI6XQRx411QEIZwwaDh7c
23634
23633
  cip
23635
23634
  cip_rust
23636
23635
  cipepser-bicycle-book-wordcount