agentaudit 3.9.8 โ†’ 3.9.10

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.
Files changed (6) hide show
  1. package/LICENSE +34 -34
  2. package/README.md +504 -504
  3. package/cli.mjs +1737 -1680
  4. package/index.mjs +605 -605
  5. package/package.json +45 -45
  6. package/prompts/audit-prompt.md +663 -663
package/README.md CHANGED
@@ -1,504 +1,504 @@
1
- <div align="center">
2
-
3
- # ๐Ÿ›ก๏ธ AgentAudit
4
-
5
- **Security scanner for AI packages โ€” MCP server + CLI**
6
-
7
- Scan MCP servers, AI skills, and packages for vulnerabilities, prompt injection,
8
- and supply chain attacks. Powered by regex static analysis and deep LLM audits.
9
-
10
- [![npm version](https://img.shields.io/npm/v/agentaudit?style=for-the-badge&color=CB3837&logo=npm)](https://www.npmjs.com/package/agentaudit)
11
- [![Trust Registry](https://img.shields.io/badge/Trust_Registry-Live-00C853?style=for-the-badge)](https://agentaudit.dev)
12
- [![License](https://img.shields.io/badge/License-AGPL_3.0-F9A825?style=for-the-badge)](LICENSE)
13
-
14
- </div>
15
-
16
- ---
17
-
18
- ## ๐Ÿ“‘ Table of Contents
19
-
20
- - [What is AgentAudit?](#what-is-agentaudit)
21
- - [Quick Start](#-quick-start)
22
- - [Commands Reference](#-commands-reference)
23
- - [Quick Scan vs Deep Audit](#-quick-scan-vs-deep-audit)
24
- - [MCP Server](#-mcp-server)
25
- - [What It Detects](#-what-it-detects)
26
- - [How the 3-Pass Audit Works](#-how-the-3-pass-audit-works)
27
- - [CI/CD Integration](#-cicd-integration)
28
- - [Configuration](#-configuration)
29
- - [Requirements](#-requirements)
30
- - [FAQ](#-faq)
31
- - [Related Links](#-related-links)
32
- - [License](#-license)
33
-
34
- ---
35
-
36
- ## What is AgentAudit?
37
-
38
- AgentAudit is a security scanner purpose-built for the AI package ecosystem. It works in two modes:
39
-
40
- 1. **CLI tool** โ€” Run `agentaudit` in your terminal to discover and scan MCP servers installed in your AI editors
41
- 2. **MCP server** โ€” Add to Claude Desktop, Cursor, or Windsurf so your AI agent can audit packages on your behalf
42
-
43
- It checks packages against the [AgentAudit Trust Registry](https://agentaudit.dev) โ€” a shared, community-driven database of security findings โ€” and can perform local scans ranging from fast regex analysis to deep LLM-powered 3-pass audits.
44
-
45
- ---
46
-
47
- ## ๐Ÿš€ Quick Start
48
-
49
- <p align="center">
50
- <img src="docs/cli-screenshot.png" alt="AgentAudit CLI โ€” discover and scan" width="700">
51
- </p>
52
-
53
- ### Option A: CLI (recommended)
54
-
55
- ```bash
56
- # Install globally (or use npx agentaudit)
57
- npm install -g agentaudit
58
-
59
- # Discover MCP servers configured in your AI editors
60
- agentaudit
61
-
62
- # Quick scan โ€” clones repo, checks code with regex patterns (~2s)
63
- agentaudit scan https://github.com/owner/repo
64
-
65
- # Deep audit โ€” clones repo, sends code to LLM for 3-pass analysis (~30s)
66
- agentaudit audit https://github.com/owner/repo
67
-
68
- # Registry lookup โ€” check if a package has been audited before (no cloning)
69
- agentaudit lookup fastmcp
70
- ```
71
-
72
- **Example output:**
73
- ```
74
- AgentAudit v3.9.0
75
- Security scanner for AI packages
76
-
77
- Discovering MCP servers in your AI editors...
78
-
79
- โ€ข Scanning Cursor ~/.cursor/mcp.json found 3 servers
80
-
81
- โ”œโ”€โ”€ tool supabase-mcp โœ” ok
82
- โ”‚ SAFE Risk 0 https://agentaudit.dev/skills/supabase-mcp
83
- โ”œโ”€โ”€ tool browser-tools-mcp โœ” ok
84
- โ”‚ โš  not audited Run: agentaudit audit https://github.com/nichochar/browser-tools-mcp
85
- โ””โ”€โ”€ tool filesystem โœ” ok
86
- โ”‚ SAFE Risk 0 https://agentaudit.dev/skills/filesystem
87
-
88
- Looking for general package scanning? Try `pip audit` or `npm audit`.
89
- ```
90
-
91
- ### Option B: MCP Server in your AI editor
92
-
93
- Add AgentAudit as an MCP server โ€” your AI agent can then discover, scan, and audit packages using its own LLM. **No extra API key needed.**
94
-
95
- <details>
96
- <summary><strong>Claude Desktop</strong> โ€” <code>~/.claude/mcp.json</code></summary>
97
-
98
- ```json
99
- {
100
- "mcpServers": {
101
- "agentaudit": {
102
- "command": "npx",
103
- "args": ["-y", "agentaudit", "--stdio"]
104
- }
105
- }
106
- }
107
- ```
108
- </details>
109
-
110
- <details>
111
- <summary><strong>Cursor</strong> โ€” <code>.cursor/mcp.json</code> (project) or <code>~/.cursor/mcp.json</code> (global)</summary>
112
-
113
- ```json
114
- {
115
- "mcpServers": {
116
- "agentaudit": {
117
- "command": "npx",
118
- "args": ["-y", "agentaudit", "--stdio"]
119
- }
120
- }
121
- }
122
- ```
123
- </details>
124
-
125
- <details>
126
- <summary><strong>Windsurf</strong> โ€” <code>~/.codeium/windsurf/mcp_config.json</code></summary>
127
-
128
- ```json
129
- {
130
- "mcpServers": {
131
- "agentaudit": {
132
- "command": "npx",
133
- "args": ["-y", "agentaudit", "--stdio"]
134
- }
135
- }
136
- }
137
- ```
138
- </details>
139
-
140
- <details>
141
- <summary><strong>VS Code</strong> โ€” <code>.vscode/mcp.json</code></summary>
142
-
143
- ```json
144
- {
145
- "servers": {
146
- "agentaudit": {
147
- "command": "npx",
148
- "args": ["-y", "agentaudit", "--stdio"]
149
- }
150
- }
151
- }
152
- ```
153
- </details>
154
-
155
- <details>
156
- <summary><strong>Continue.dev</strong> โ€” <code>~/.continue/config.json</code></summary>
157
-
158
- Add to the `mcpServers` section of your existing config:
159
- ```json
160
- {
161
- "mcpServers": [
162
- {
163
- "name": "agentaudit",
164
- "command": "npx",
165
- "args": ["-y", "agentaudit", "--stdio"]
166
- }
167
- ]
168
- }
169
- ```
170
- </details>
171
-
172
- <details>
173
- <summary><strong>Zed</strong> โ€” <code>~/.config/zed/settings.json</code></summary>
174
-
175
- ```json
176
- {
177
- "context_servers": {
178
- "agentaudit": {
179
- "command": {
180
- "path": "npx",
181
- "args": ["-y", "agentaudit", "--stdio"]
182
- }
183
- }
184
- }
185
- }
186
- ```
187
- </details>
188
-
189
- Then ask your agent: *"Check which MCP servers I have installed and audit any unaudited ones."*
190
-
191
- ---
192
-
193
- ## ๐Ÿ“‹ Commands Reference
194
-
195
- | Command | Description | Example |
196
- |---------|-------------|---------|
197
- | `agentaudit` | Discover MCP servers (default, same as `discover`) | `agentaudit` |
198
- | `agentaudit discover` | Find MCP servers in Cursor, Claude, VS Code, Windsurf | `agentaudit discover` |
199
- | `agentaudit discover --quick` | Discover + auto-scan all servers | `agentaudit discover --quick` |
200
- | `agentaudit discover --deep` | Discover + interactively select servers to deep-audit | `agentaudit discover --deep` |
201
- | `agentaudit scan <url>` | Quick regex-based static scan (~2s) | `agentaudit scan https://github.com/owner/repo` |
202
- | `agentaudit scan <url> --deep` | Deep audit (same as `audit`) | `agentaudit scan https://github.com/owner/repo --deep` |
203
- | `agentaudit audit <url>` | Deep LLM-powered 3-pass audit (~30s) | `agentaudit audit https://github.com/owner/repo` |
204
- | `agentaudit lookup <name>` | Look up package in trust registry | `agentaudit lookup fastmcp` |
205
- | `agentaudit setup` | Register agent + configure API key | `agentaudit setup` |
206
-
207
- ### Global Flags
208
-
209
- | Flag | Description |
210
- |------|-------------|
211
- | `--json` | Output machine-readable JSON to stdout |
212
- | `--quiet` / `-q` | Suppress banner and decorative output (show findings only) |
213
- | `--no-color` | Disable ANSI colors (also respects `NO_COLOR` env var) |
214
- | `--help` / `-h` | Show help text |
215
- | `-v` / `--version` | Show version |
216
-
217
- ### Exit Codes
218
-
219
- | Code | Meaning |
220
- |------|---------|
221
- | `0` | Clean โ€” no findings detected, or successful lookup |
222
- | `1` | Findings detected |
223
- | `2` | Error (clone failed, network error, invalid args) |
224
-
225
- ---
226
-
227
- ## โš–๏ธ Quick Scan vs Deep Audit
228
-
229
- | | Quick Scan (`scan`) | Deep Audit (`audit`) |
230
- |---|---------------------|---------------------|
231
- | **Speed** | ~2 seconds | ~30 seconds |
232
- | **Method** | Regex pattern matching | LLM-powered 3-pass analysis |
233
- | **API key needed** | No | Yes (`ANTHROPIC_API_KEY` or `OPENAI_API_KEY`) |
234
- | **False positives** | Higher (regex limitations) | Very low (context-aware) |
235
- | **Detects** | Common patterns (injection, secrets, eval) | Complex attack chains, AI-specific threats, obfuscation |
236
- | **Best for** | Quick triage, CI pipelines | Critical packages, pre-production review |
237
-
238
- **Tip:** Use `agentaudit scan <url> --deep` to run a deep audit via the scan command.
239
-
240
- ---
241
-
242
- ## ๐Ÿ”Œ MCP Server
243
-
244
- When running as an MCP server, AgentAudit exposes the following tools to your AI agent:
245
-
246
- | Tool | Description |
247
- |------|-------------|
248
- | `audit_package` | Deep LLM-powered audit of a repository |
249
- | `check_registry` | Look up a package in the trust registry |
250
- | `submit_report` | Upload audit findings to the registry |
251
- | `discover_servers` | Find MCP servers in local editor configs |
252
-
253
- ### Workflow
254
-
255
- ```
256
- User asks agent to install a package
257
- โ”‚
258
- โ–ผ
259
- Agent calls check_registry(package_name)
260
- โ”‚
261
- โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”
262
- โ”‚ โ”‚
263
- Found Not Found
264
- โ”‚ โ”‚
265
- โ–ผ โ–ผ
266
- Return Agent calls audit_package(repo_url)
267
- score โ”‚
268
- โ–ผ
269
- LLM analyzes code (3-pass)
270
- โ”‚
271
- โ–ผ
272
- Agent calls submit_report(findings)
273
- โ”‚
274
- โ–ผ
275
- Return findings + risk score
276
- ```
277
-
278
- ---
279
-
280
- ## ๐ŸŽฏ What It Detects
281
-
282
- <table>
283
- <tr>
284
- <td>
285
-
286
- **Core Security**
287
-
288
- ![Command Injection](https://img.shields.io/badge/-Command_Injection-E53935?style=flat-square)
289
- ![Credential Theft](https://img.shields.io/badge/-Credential_Theft-E53935?style=flat-square)
290
- ![Data Exfiltration](https://img.shields.io/badge/-Data_Exfiltration-E53935?style=flat-square)
291
- ![SQL Injection](https://img.shields.io/badge/-SQL_Injection-E53935?style=flat-square)
292
- ![Path Traversal](https://img.shields.io/badge/-Path_Traversal-E53935?style=flat-square)
293
- ![Unsafe Deserialization](https://img.shields.io/badge/-Unsafe_Deserialization-E53935?style=flat-square)
294
-
295
- </td>
296
- <td>
297
-
298
- **AI-Specific**
299
-
300
- ![Prompt Injection](https://img.shields.io/badge/-Prompt_Injection-7B1FA2?style=flat-square)
301
- ![Jailbreak](https://img.shields.io/badge/-Jailbreak-7B1FA2?style=flat-square)
302
- ![Agent Impersonation](https://img.shields.io/badge/-Agent_Impersonation-7B1FA2?style=flat-square)
303
- ![Capability Escalation](https://img.shields.io/badge/-Capability_Escalation-7B1FA2?style=flat-square)
304
- ![Context Pollution](https://img.shields.io/badge/-Context_Pollution-7B1FA2?style=flat-square)
305
- ![Hidden Instructions](https://img.shields.io/badge/-Hidden_Instructions-7B1FA2?style=flat-square)
306
-
307
- </td>
308
- </tr>
309
- <tr>
310
- <td>
311
-
312
- **MCP-Specific**
313
-
314
- ![Tool Poisoning](https://img.shields.io/badge/-Tool_Poisoning-FF6F00?style=flat-square)
315
- ![Desc Injection](https://img.shields.io/badge/-Desc_Injection-FF6F00?style=flat-square)
316
- ![Resource Traversal](https://img.shields.io/badge/-Resource_Traversal-FF6F00?style=flat-square)
317
- ![Unpinned npx](https://img.shields.io/badge/-Unpinned_npx-FF6F00?style=flat-square)
318
- ![Broad Permissions](https://img.shields.io/badge/-Broad_Permissions-FF6F00?style=flat-square)
319
-
320
- </td>
321
- <td>
322
-
323
- **Persistence & Obfuscation**
324
-
325
- ![Crontab Mod](https://img.shields.io/badge/-Crontab_Mod-455A64?style=flat-square)
326
- ![Shell RC Inject](https://img.shields.io/badge/-Shell_RC_Inject-455A64?style=flat-square)
327
- ![Git Hook Abuse](https://img.shields.io/badge/-Git_Hook_Abuse-455A64?style=flat-square)
328
- ![Zero-Width Chars](https://img.shields.io/badge/-Zero--Width_Chars-455A64?style=flat-square)
329
- ![Base64 Exec](https://img.shields.io/badge/-Base64_Exec-455A64?style=flat-square)
330
- ![ANSI Escape](https://img.shields.io/badge/-ANSI_Escape-455A64?style=flat-square)
331
-
332
- </td>
333
- </tr>
334
- </table>
335
-
336
- ---
337
-
338
- ## ๐Ÿง  How the 3-Pass Audit Works
339
-
340
- The deep audit (`agentaudit audit`) uses a structured 3-phase LLM analysis โ€” not a single-shot prompt, but a rigorous multi-pass process:
341
-
342
- | Phase | Name | What Happens |
343
- |-------|------|-------------|
344
- | **1** | ๐Ÿ” **UNDERSTAND** | Read all files and build a **Package Profile**: purpose, category, expected behaviors, trust boundaries. No scanning yet โ€” the goal is to understand what the package *should* do before looking for what it *shouldn't*. |
345
- | **2** | ๐ŸŽฏ **DETECT** | Evidence collection against **50+ detection patterns** across 8 categories (AI-specific, MCP, persistence, obfuscation, cross-file correlation). Only facts are recorded โ€” no severity judgments yet. |
346
- | **3** | โš–๏ธ **CLASSIFY** | Every finding goes through a **Mandatory Self-Check** (5 questions), **Exploitability Assessment**, and **Confidence Gating**. HIGH/CRITICAL findings must survive a **Devil's Advocate** challenge and include a full **Reasoning Chain**. |
347
-
348
- **Why 3 passes?** Single-pass analysis is the #1 cause of false positives. By separating understanding โ†’ detection โ†’ classification:
349
-
350
- - Phase 1 prevents flagging core functionality as suspicious (e.g., SQL execution in a database tool)
351
- - Phase 2 ensures evidence is collected without severity bias
352
- - Phase 3 catches false positives before they reach the report
353
-
354
- This architecture achieved **0% false positives** on our 11-package test set, down from 42% in v2.
355
-
356
- ---
357
-
358
- ## ๐Ÿ”„ CI/CD Integration
359
-
360
- AgentAudit is designed for CI pipelines with proper exit codes and JSON output:
361
-
362
- ```yaml
363
- # GitHub Actions example
364
- - name: Scan MCP servers
365
- run: |
366
- npx agentaudit scan https://github.com/org/mcp-server --json --quiet > results.json
367
- # Exit code 1 = findings detected โ†’ fail the build
368
- ```
369
-
370
- ```bash
371
- # Shell scripting
372
- agentaudit scan https://github.com/owner/repo --json --quiet 2>/dev/null
373
- if [ $? -eq 1 ]; then
374
- echo "Security findings detected!"
375
- exit 1
376
- fi
377
- ```
378
-
379
- ### JSON Output Examples
380
-
381
- ```bash
382
- # Scan with JSON output
383
- agentaudit scan https://github.com/owner/repo --json
384
- ```
385
-
386
- ```json
387
- {
388
- "slug": "repo",
389
- "url": "https://github.com/owner/repo",
390
- "findings": [
391
- {
392
- "severity": "high",
393
- "title": "Command injection risk",
394
- "file": "src/handler.js",
395
- "line": 42,
396
- "snippet": "exec(`git ${userInput}`)"
397
- }
398
- ],
399
- "fileCount": 15,
400
- "duration": "1.8s"
401
- }
402
- ```
403
-
404
- ```bash
405
- # Registry lookup with JSON
406
- agentaudit lookup fastmcp --json
407
- ```
408
-
409
- > **Coming soon:** `--fail-on <severity>` flag to set minimum severity threshold for non-zero exit (e.g., `--fail-on high` ignores low/medium findings).
410
-
411
- ---
412
-
413
- ## โš™๏ธ Configuration
414
-
415
- ### Credentials
416
-
417
- AgentAudit stores credentials in `~/.config/agentaudit/credentials.json` (or `$XDG_CONFIG_HOME/agentaudit/credentials.json`).
418
-
419
- Run `agentaudit setup` to configure interactively, or set via environment:
420
-
421
- ```bash
422
- export AGENTAUDIT_API_KEY=asf_your_key_here
423
- ```
424
-
425
- ### Environment Variables
426
-
427
- | Variable | Description |
428
- |----------|-------------|
429
- | `AGENTAUDIT_API_KEY` | API key for registry access |
430
- | `ANTHROPIC_API_KEY` | Anthropic API key for deep audits (Claude) |
431
- | `OPENAI_API_KEY` | OpenAI API key for deep audits (GPT-4o) |
432
- | `NO_COLOR` | Disable ANSI colors ([no-color.org](https://no-color.org)) |
433
-
434
- ---
435
-
436
- ## ๐Ÿ“ฆ Requirements
437
-
438
- - **Node.js** โ‰ฅ 18.0.0
439
- - **Git** (for cloning repositories during scan/audit)
440
-
441
- ---
442
-
443
- ## โ“ FAQ
444
-
445
- ### How do I set up AgentAudit?
446
-
447
- ```bash
448
- npm install -g agentaudit
449
- agentaudit setup
450
- ```
451
-
452
- Or use without installing: `npx agentaudit`
453
-
454
- ### Do I need an API key?
455
-
456
- - **Quick scan** (`scan`): No API key needed โ€” runs locally with regex
457
- - **Deep audit** (`audit`): Needs `ANTHROPIC_API_KEY` or `OPENAI_API_KEY`
458
- - **Registry lookup** (`lookup`): No key needed for reading; key needed for uploading reports
459
- - **MCP server**: No extra key needed โ€” uses the host editor's LLM
460
-
461
- ### What data is sent externally?
462
-
463
- - **Registry lookups**: Package name/slug is sent to `agentaudit.dev` to check for existing audits
464
- - **Report uploads**: Audit findings are uploaded to the public registry (requires API key)
465
- - **Deep audits**: Source code is sent to Anthropic or OpenAI for LLM analysis
466
- - **Quick scans**: Everything stays local โ€” no data leaves your machine
467
-
468
- ### Can I use it offline?
469
-
470
- Quick scans (`agentaudit scan`) work fully offline after cloning. Registry lookups and deep audits require network access.
471
-
472
- ### Can I use it as an MCP server without the CLI?
473
-
474
- Yes! `npx agentaudit` starts the MCP server when invoked by an editor. The CLI and MCP server are the same package โ€” behavior is determined by how it's called.
475
-
476
- ### How does `discover` know which editors I use?
477
-
478
- It checks standard config file locations for Claude Desktop, Cursor, VS Code, and Windsurf. It also checks the current working directory for project-level `.cursor/mcp.json` and `.vscode/mcp.json`.
479
-
480
- ---
481
-
482
- ## ๐Ÿ”— Related Links
483
-
484
- - **Trust Registry**: [agentaudit.dev](https://agentaudit.dev)
485
- - **Leaderboard**: [agentaudit.dev/leaderboard](https://agentaudit.dev/leaderboard)
486
- - **Agent Skill**: [github.com/starbuck100/agentaudit-skill](https://github.com/starbuck100/agentaudit-skill) โ€” Full agent skill with pre-install security gate, detection patterns & peer review system
487
- - **MCP Server Repository**: [github.com/starbuck100/agentaudit-mcp](https://github.com/starbuck100/agentaudit-mcp)
488
- - **Report Issues**: [GitHub Issues](https://github.com/starbuck100/agentaudit-mcp/issues)
489
-
490
- ---
491
-
492
- ## ๐Ÿ“„ License
493
-
494
- [AGPL-3.0](LICENSE) โ€” Free for open source use. Commercial license available for proprietary integrations.
495
-
496
- ---
497
-
498
- <div align="center">
499
-
500
- **Protect your AI stack. Scan before you trust.**
501
-
502
- [Trust Registry](https://agentaudit.dev) ยท [Leaderboard](https://agentaudit.dev/leaderboard) ยท [Report Issues](https://github.com/starbuck100/agentaudit-mcp/issues)
503
-
504
- </div>
1
+ <div align="center">
2
+
3
+ # ๐Ÿ›ก๏ธ AgentAudit
4
+
5
+ **Security scanner for AI packages โ€” MCP server + CLI**
6
+
7
+ Scan MCP servers, AI skills, and packages for vulnerabilities, prompt injection,
8
+ and supply chain attacks. Powered by regex static analysis and deep LLM audits.
9
+
10
+ [![npm version](https://img.shields.io/npm/v/agentaudit?style=for-the-badge&color=CB3837&logo=npm)](https://www.npmjs.com/package/agentaudit)
11
+ [![Trust Registry](https://img.shields.io/badge/Trust_Registry-Live-00C853?style=for-the-badge)](https://agentaudit.dev)
12
+ [![License](https://img.shields.io/badge/License-AGPL_3.0-F9A825?style=for-the-badge)](LICENSE)
13
+
14
+ </div>
15
+
16
+ ---
17
+
18
+ ## ๐Ÿ“‘ Table of Contents
19
+
20
+ - [What is AgentAudit?](#what-is-agentaudit)
21
+ - [Quick Start](#-quick-start)
22
+ - [Commands Reference](#-commands-reference)
23
+ - [Quick Scan vs Deep Audit](#-quick-scan-vs-deep-audit)
24
+ - [MCP Server](#-mcp-server)
25
+ - [What It Detects](#-what-it-detects)
26
+ - [How the 3-Pass Audit Works](#-how-the-3-pass-audit-works)
27
+ - [CI/CD Integration](#-cicd-integration)
28
+ - [Configuration](#-configuration)
29
+ - [Requirements](#-requirements)
30
+ - [FAQ](#-faq)
31
+ - [Related Links](#-related-links)
32
+ - [License](#-license)
33
+
34
+ ---
35
+
36
+ ## What is AgentAudit?
37
+
38
+ AgentAudit is a security scanner purpose-built for the AI package ecosystem. It works in two modes:
39
+
40
+ 1. **CLI tool** โ€” Run `agentaudit` in your terminal to discover and scan MCP servers installed in your AI editors
41
+ 2. **MCP server** โ€” Add to Claude Desktop, Cursor, or Windsurf so your AI agent can audit packages on your behalf
42
+
43
+ It checks packages against the [AgentAudit Trust Registry](https://agentaudit.dev) โ€” a shared, community-driven database of security findings โ€” and can perform local scans ranging from fast regex analysis to deep LLM-powered 3-pass audits.
44
+
45
+ ---
46
+
47
+ ## ๐Ÿš€ Quick Start
48
+
49
+ <p align="center">
50
+ <img src="docs/cli-screenshot.png" alt="AgentAudit CLI โ€” discover and scan" width="700">
51
+ </p>
52
+
53
+ ### Option A: CLI (recommended)
54
+
55
+ ```bash
56
+ # Install globally (or use npx agentaudit)
57
+ npm install -g agentaudit
58
+
59
+ # Discover MCP servers configured in your AI editors
60
+ agentaudit
61
+
62
+ # Quick scan โ€” clones repo, checks code with regex patterns (~2s)
63
+ agentaudit scan https://github.com/owner/repo
64
+
65
+ # Deep audit โ€” clones repo, sends code to LLM for 3-pass analysis (~30s)
66
+ agentaudit audit https://github.com/owner/repo
67
+
68
+ # Registry lookup โ€” check if a package has been audited before (no cloning)
69
+ agentaudit lookup fastmcp
70
+ ```
71
+
72
+ **Example output:**
73
+ ```
74
+ AgentAudit v3.9.8
75
+ Security scanner for AI packages
76
+
77
+ Discovering MCP servers in your AI editors...
78
+
79
+ โ€ข Scanning Cursor ~/.cursor/mcp.json found 3 servers
80
+
81
+ โ”œโ”€โ”€ tool supabase-mcp โœ” ok
82
+ โ”‚ SAFE Risk 0 https://agentaudit.dev/skills/supabase-mcp
83
+ โ”œโ”€โ”€ tool browser-tools-mcp โœ” ok
84
+ โ”‚ โš  not audited Run: agentaudit audit https://github.com/nichochar/browser-tools-mcp
85
+ โ””โ”€โ”€ tool filesystem โœ” ok
86
+ โ”‚ SAFE Risk 0 https://agentaudit.dev/skills/filesystem
87
+
88
+ Looking for general package scanning? Try `pip audit` or `npm audit`.
89
+ ```
90
+
91
+ ### Option B: MCP Server in your AI editor
92
+
93
+ Add AgentAudit as an MCP server โ€” your AI agent can then discover, scan, and audit packages using its own LLM. **No extra API key needed.**
94
+
95
+ <details>
96
+ <summary><strong>Claude Desktop</strong> โ€” <code>~/.claude/mcp.json</code></summary>
97
+
98
+ ```json
99
+ {
100
+ "mcpServers": {
101
+ "agentaudit": {
102
+ "command": "npx",
103
+ "args": ["-y", "agentaudit", "--stdio"]
104
+ }
105
+ }
106
+ }
107
+ ```
108
+ </details>
109
+
110
+ <details>
111
+ <summary><strong>Cursor</strong> โ€” <code>.cursor/mcp.json</code> (project) or <code>~/.cursor/mcp.json</code> (global)</summary>
112
+
113
+ ```json
114
+ {
115
+ "mcpServers": {
116
+ "agentaudit": {
117
+ "command": "npx",
118
+ "args": ["-y", "agentaudit", "--stdio"]
119
+ }
120
+ }
121
+ }
122
+ ```
123
+ </details>
124
+
125
+ <details>
126
+ <summary><strong>Windsurf</strong> โ€” <code>~/.codeium/windsurf/mcp_config.json</code></summary>
127
+
128
+ ```json
129
+ {
130
+ "mcpServers": {
131
+ "agentaudit": {
132
+ "command": "npx",
133
+ "args": ["-y", "agentaudit", "--stdio"]
134
+ }
135
+ }
136
+ }
137
+ ```
138
+ </details>
139
+
140
+ <details>
141
+ <summary><strong>VS Code</strong> โ€” <code>.vscode/mcp.json</code></summary>
142
+
143
+ ```json
144
+ {
145
+ "servers": {
146
+ "agentaudit": {
147
+ "command": "npx",
148
+ "args": ["-y", "agentaudit", "--stdio"]
149
+ }
150
+ }
151
+ }
152
+ ```
153
+ </details>
154
+
155
+ <details>
156
+ <summary><strong>Continue.dev</strong> โ€” <code>~/.continue/config.json</code></summary>
157
+
158
+ Add to the `mcpServers` section of your existing config:
159
+ ```json
160
+ {
161
+ "mcpServers": [
162
+ {
163
+ "name": "agentaudit",
164
+ "command": "npx",
165
+ "args": ["-y", "agentaudit", "--stdio"]
166
+ }
167
+ ]
168
+ }
169
+ ```
170
+ </details>
171
+
172
+ <details>
173
+ <summary><strong>Zed</strong> โ€” <code>~/.config/zed/settings.json</code></summary>
174
+
175
+ ```json
176
+ {
177
+ "context_servers": {
178
+ "agentaudit": {
179
+ "command": {
180
+ "path": "npx",
181
+ "args": ["-y", "agentaudit", "--stdio"]
182
+ }
183
+ }
184
+ }
185
+ }
186
+ ```
187
+ </details>
188
+
189
+ Then ask your agent: *"Check which MCP servers I have installed and audit any unaudited ones."*
190
+
191
+ ---
192
+
193
+ ## ๐Ÿ“‹ Commands Reference
194
+
195
+ | Command | Description | Example |
196
+ |---------|-------------|---------|
197
+ | `agentaudit` | Discover MCP servers (default, same as `discover`) | `agentaudit` |
198
+ | `agentaudit discover` | Find MCP servers in Cursor, Claude, VS Code, Windsurf | `agentaudit discover` |
199
+ | `agentaudit discover --quick` | Discover + auto-scan all servers | `agentaudit discover --quick` |
200
+ | `agentaudit discover --deep` | Discover + interactively select servers to deep-audit | `agentaudit discover --deep` |
201
+ | `agentaudit scan <url>` | Quick regex-based static scan (~2s) | `agentaudit scan https://github.com/owner/repo` |
202
+ | `agentaudit scan <url> --deep` | Deep audit (same as `audit`) | `agentaudit scan https://github.com/owner/repo --deep` |
203
+ | `agentaudit audit <url>` | Deep LLM-powered 3-pass audit (~30s) | `agentaudit audit https://github.com/owner/repo` |
204
+ | `agentaudit lookup <name>` | Look up package in trust registry | `agentaudit lookup fastmcp` |
205
+ | `agentaudit setup` | Register agent + configure API key | `agentaudit setup` |
206
+
207
+ ### Global Flags
208
+
209
+ | Flag | Description |
210
+ |------|-------------|
211
+ | `--json` | Output machine-readable JSON to stdout |
212
+ | `--quiet` / `-q` | Suppress banner and decorative output (show findings only) |
213
+ | `--no-color` | Disable ANSI colors (also respects `NO_COLOR` env var) |
214
+ | `--help` / `-h` | Show help text |
215
+ | `-v` / `--version` | Show version |
216
+
217
+ ### Exit Codes
218
+
219
+ | Code | Meaning |
220
+ |------|---------|
221
+ | `0` | Clean โ€” no findings detected, or successful lookup |
222
+ | `1` | Findings detected |
223
+ | `2` | Error (clone failed, network error, invalid args) |
224
+
225
+ ---
226
+
227
+ ## โš–๏ธ Quick Scan vs Deep Audit
228
+
229
+ | | Quick Scan (`scan`) | Deep Audit (`audit`) |
230
+ |---|---------------------|---------------------|
231
+ | **Speed** | ~2 seconds | ~30 seconds |
232
+ | **Method** | Regex pattern matching | LLM-powered 3-pass analysis |
233
+ | **API key needed** | No | Yes (`ANTHROPIC_API_KEY` or `OPENAI_API_KEY`) |
234
+ | **False positives** | Higher (regex limitations) | Very low (context-aware) |
235
+ | **Detects** | Common patterns (injection, secrets, eval) | Complex attack chains, AI-specific threats, obfuscation |
236
+ | **Best for** | Quick triage, CI pipelines | Critical packages, pre-production review |
237
+
238
+ **Tip:** Use `agentaudit scan <url> --deep` to run a deep audit via the scan command.
239
+
240
+ ---
241
+
242
+ ## ๐Ÿ”Œ MCP Server
243
+
244
+ When running as an MCP server, AgentAudit exposes the following tools to your AI agent:
245
+
246
+ | Tool | Description |
247
+ |------|-------------|
248
+ | `audit_package` | Deep LLM-powered audit of a repository |
249
+ | `check_registry` | Look up a package in the trust registry |
250
+ | `submit_report` | Upload audit findings to the registry |
251
+ | `discover_servers` | Find MCP servers in local editor configs |
252
+
253
+ ### Workflow
254
+
255
+ ```
256
+ User asks agent to install a package
257
+ โ”‚
258
+ โ–ผ
259
+ Agent calls check_registry(package_name)
260
+ โ”‚
261
+ โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”
262
+ โ”‚ โ”‚
263
+ Found Not Found
264
+ โ”‚ โ”‚
265
+ โ–ผ โ–ผ
266
+ Return Agent calls audit_package(repo_url)
267
+ score โ”‚
268
+ โ–ผ
269
+ LLM analyzes code (3-pass)
270
+ โ”‚
271
+ โ–ผ
272
+ Agent calls submit_report(findings)
273
+ โ”‚
274
+ โ–ผ
275
+ Return findings + risk score
276
+ ```
277
+
278
+ ---
279
+
280
+ ## ๐ŸŽฏ What It Detects
281
+
282
+ <table>
283
+ <tr>
284
+ <td>
285
+
286
+ **Core Security**
287
+
288
+ ![Command Injection](https://img.shields.io/badge/-Command_Injection-E53935?style=flat-square)
289
+ ![Credential Theft](https://img.shields.io/badge/-Credential_Theft-E53935?style=flat-square)
290
+ ![Data Exfiltration](https://img.shields.io/badge/-Data_Exfiltration-E53935?style=flat-square)
291
+ ![SQL Injection](https://img.shields.io/badge/-SQL_Injection-E53935?style=flat-square)
292
+ ![Path Traversal](https://img.shields.io/badge/-Path_Traversal-E53935?style=flat-square)
293
+ ![Unsafe Deserialization](https://img.shields.io/badge/-Unsafe_Deserialization-E53935?style=flat-square)
294
+
295
+ </td>
296
+ <td>
297
+
298
+ **AI-Specific**
299
+
300
+ ![Prompt Injection](https://img.shields.io/badge/-Prompt_Injection-7B1FA2?style=flat-square)
301
+ ![Jailbreak](https://img.shields.io/badge/-Jailbreak-7B1FA2?style=flat-square)
302
+ ![Agent Impersonation](https://img.shields.io/badge/-Agent_Impersonation-7B1FA2?style=flat-square)
303
+ ![Capability Escalation](https://img.shields.io/badge/-Capability_Escalation-7B1FA2?style=flat-square)
304
+ ![Context Pollution](https://img.shields.io/badge/-Context_Pollution-7B1FA2?style=flat-square)
305
+ ![Hidden Instructions](https://img.shields.io/badge/-Hidden_Instructions-7B1FA2?style=flat-square)
306
+
307
+ </td>
308
+ </tr>
309
+ <tr>
310
+ <td>
311
+
312
+ **MCP-Specific**
313
+
314
+ ![Tool Poisoning](https://img.shields.io/badge/-Tool_Poisoning-FF6F00?style=flat-square)
315
+ ![Desc Injection](https://img.shields.io/badge/-Desc_Injection-FF6F00?style=flat-square)
316
+ ![Resource Traversal](https://img.shields.io/badge/-Resource_Traversal-FF6F00?style=flat-square)
317
+ ![Unpinned npx](https://img.shields.io/badge/-Unpinned_npx-FF6F00?style=flat-square)
318
+ ![Broad Permissions](https://img.shields.io/badge/-Broad_Permissions-FF6F00?style=flat-square)
319
+
320
+ </td>
321
+ <td>
322
+
323
+ **Persistence & Obfuscation**
324
+
325
+ ![Crontab Mod](https://img.shields.io/badge/-Crontab_Mod-455A64?style=flat-square)
326
+ ![Shell RC Inject](https://img.shields.io/badge/-Shell_RC_Inject-455A64?style=flat-square)
327
+ ![Git Hook Abuse](https://img.shields.io/badge/-Git_Hook_Abuse-455A64?style=flat-square)
328
+ ![Zero-Width Chars](https://img.shields.io/badge/-Zero--Width_Chars-455A64?style=flat-square)
329
+ ![Base64 Exec](https://img.shields.io/badge/-Base64_Exec-455A64?style=flat-square)
330
+ ![ANSI Escape](https://img.shields.io/badge/-ANSI_Escape-455A64?style=flat-square)
331
+
332
+ </td>
333
+ </tr>
334
+ </table>
335
+
336
+ ---
337
+
338
+ ## ๐Ÿง  How the 3-Pass Audit Works
339
+
340
+ The deep audit (`agentaudit audit`) uses a structured 3-phase LLM analysis โ€” not a single-shot prompt, but a rigorous multi-pass process:
341
+
342
+ | Phase | Name | What Happens |
343
+ |-------|------|-------------|
344
+ | **1** | ๐Ÿ” **UNDERSTAND** | Read all files and build a **Package Profile**: purpose, category, expected behaviors, trust boundaries. No scanning yet โ€” the goal is to understand what the package *should* do before looking for what it *shouldn't*. |
345
+ | **2** | ๐ŸŽฏ **DETECT** | Evidence collection against **50+ detection patterns** across 8 categories (AI-specific, MCP, persistence, obfuscation, cross-file correlation). Only facts are recorded โ€” no severity judgments yet. |
346
+ | **3** | โš–๏ธ **CLASSIFY** | Every finding goes through a **Mandatory Self-Check** (5 questions), **Exploitability Assessment**, and **Confidence Gating**. HIGH/CRITICAL findings must survive a **Devil's Advocate** challenge and include a full **Reasoning Chain**. |
347
+
348
+ **Why 3 passes?** Single-pass analysis is the #1 cause of false positives. By separating understanding โ†’ detection โ†’ classification:
349
+
350
+ - Phase 1 prevents flagging core functionality as suspicious (e.g., SQL execution in a database tool)
351
+ - Phase 2 ensures evidence is collected without severity bias
352
+ - Phase 3 catches false positives before they reach the report
353
+
354
+ This architecture achieved **0% false positives** on our 11-package test set, down from 42% in v2.
355
+
356
+ ---
357
+
358
+ ## ๐Ÿ”„ CI/CD Integration
359
+
360
+ AgentAudit is designed for CI pipelines with proper exit codes and JSON output:
361
+
362
+ ```yaml
363
+ # GitHub Actions example
364
+ - name: Scan MCP servers
365
+ run: |
366
+ npx agentaudit scan https://github.com/org/mcp-server --json --quiet > results.json
367
+ # Exit code 1 = findings detected โ†’ fail the build
368
+ ```
369
+
370
+ ```bash
371
+ # Shell scripting
372
+ agentaudit scan https://github.com/owner/repo --json --quiet 2>/dev/null
373
+ if [ $? -eq 1 ]; then
374
+ echo "Security findings detected!"
375
+ exit 1
376
+ fi
377
+ ```
378
+
379
+ ### JSON Output Examples
380
+
381
+ ```bash
382
+ # Scan with JSON output
383
+ agentaudit scan https://github.com/owner/repo --json
384
+ ```
385
+
386
+ ```json
387
+ {
388
+ "slug": "repo",
389
+ "url": "https://github.com/owner/repo",
390
+ "findings": [
391
+ {
392
+ "severity": "high",
393
+ "title": "Command injection risk",
394
+ "file": "src/handler.js",
395
+ "line": 42,
396
+ "snippet": "exec(`git ${userInput}`)"
397
+ }
398
+ ],
399
+ "fileCount": 15,
400
+ "duration": "1.8s"
401
+ }
402
+ ```
403
+
404
+ ```bash
405
+ # Registry lookup with JSON
406
+ agentaudit lookup fastmcp --json
407
+ ```
408
+
409
+ > **Coming soon:** `--fail-on <severity>` flag to set minimum severity threshold for non-zero exit (e.g., `--fail-on high` ignores low/medium findings).
410
+
411
+ ---
412
+
413
+ ## โš™๏ธ Configuration
414
+
415
+ ### Credentials
416
+
417
+ AgentAudit stores credentials in `~/.config/agentaudit/credentials.json` (or `$XDG_CONFIG_HOME/agentaudit/credentials.json`).
418
+
419
+ Run `agentaudit setup` to configure interactively, or set via environment:
420
+
421
+ ```bash
422
+ export AGENTAUDIT_API_KEY=asf_your_key_here
423
+ ```
424
+
425
+ ### Environment Variables
426
+
427
+ | Variable | Description |
428
+ |----------|-------------|
429
+ | `AGENTAUDIT_API_KEY` | API key for registry access |
430
+ | `ANTHROPIC_API_KEY` | Anthropic API key for deep audits (Claude) |
431
+ | `OPENAI_API_KEY` | OpenAI API key for deep audits (GPT-4o) |
432
+ | `NO_COLOR` | Disable ANSI colors ([no-color.org](https://no-color.org)) |
433
+
434
+ ---
435
+
436
+ ## ๐Ÿ“ฆ Requirements
437
+
438
+ - **Node.js** โ‰ฅ 18.0.0
439
+ - **Git** (for cloning repositories during scan/audit)
440
+
441
+ ---
442
+
443
+ ## โ“ FAQ
444
+
445
+ ### How do I set up AgentAudit?
446
+
447
+ ```bash
448
+ npm install -g agentaudit
449
+ agentaudit setup
450
+ ```
451
+
452
+ Or use without installing: `npx agentaudit`
453
+
454
+ ### Do I need an API key?
455
+
456
+ - **Quick scan** (`scan`): No API key needed โ€” runs locally with regex
457
+ - **Deep audit** (`audit`): Needs `ANTHROPIC_API_KEY` or `OPENAI_API_KEY`
458
+ - **Registry lookup** (`lookup`): No key needed for reading; key needed for uploading reports
459
+ - **MCP server**: No extra key needed โ€” uses the host editor's LLM
460
+
461
+ ### What data is sent externally?
462
+
463
+ - **Registry lookups**: Package name/slug is sent to `agentaudit.dev` to check for existing audits
464
+ - **Report uploads**: Audit findings are uploaded to the public registry (requires API key)
465
+ - **Deep audits**: Source code is sent to Anthropic or OpenAI for LLM analysis
466
+ - **Quick scans**: Everything stays local โ€” no data leaves your machine
467
+
468
+ ### Can I use it offline?
469
+
470
+ Quick scans (`agentaudit scan`) work fully offline after cloning. Registry lookups and deep audits require network access.
471
+
472
+ ### Can I use it as an MCP server without the CLI?
473
+
474
+ Yes! `npx agentaudit` starts the MCP server when invoked by an editor. The CLI and MCP server are the same package โ€” behavior is determined by how it's called.
475
+
476
+ ### How does `discover` know which editors I use?
477
+
478
+ It checks standard config file locations for Claude Desktop, Cursor, VS Code, and Windsurf. It also checks the current working directory for project-level `.cursor/mcp.json` and `.vscode/mcp.json`.
479
+
480
+ ---
481
+
482
+ ## ๐Ÿ”— Related Links
483
+
484
+ - **Trust Registry**: [agentaudit.dev](https://agentaudit.dev)
485
+ - **Leaderboard**: [agentaudit.dev/leaderboard](https://agentaudit.dev/leaderboard)
486
+ - **Agent Skill**: [github.com/starbuck100/agentaudit-skill](https://github.com/starbuck100/agentaudit-skill) โ€” Full agent skill with pre-install security gate, detection patterns & peer review system
487
+ - **MCP Server Repository**: [github.com/starbuck100/agentaudit-mcp](https://github.com/starbuck100/agentaudit-mcp)
488
+ - **Report Issues**: [GitHub Issues](https://github.com/starbuck100/agentaudit-mcp/issues)
489
+
490
+ ---
491
+
492
+ ## ๐Ÿ“„ License
493
+
494
+ [AGPL-3.0](LICENSE) โ€” Free for open source use. Commercial license available for proprietary integrations.
495
+
496
+ ---
497
+
498
+ <div align="center">
499
+
500
+ **Protect your AI stack. Scan before you trust.**
501
+
502
+ [Trust Registry](https://agentaudit.dev) ยท [Leaderboard](https://agentaudit.dev/leaderboard) ยท [Report Issues](https://github.com/starbuck100/agentaudit-mcp/issues)
503
+
504
+ </div>