aegismcp-security 3.1.0__tar.gz

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 (41) hide show
  1. aegismcp_security-3.1.0/LICENSE +21 -0
  2. aegismcp_security-3.1.0/PKG-INFO +572 -0
  3. aegismcp_security-3.1.0/README.md +539 -0
  4. aegismcp_security-3.1.0/pyproject.toml +53 -0
  5. aegismcp_security-3.1.0/setup.cfg +4 -0
  6. aegismcp_security-3.1.0/src/aegismcp/__init__.py +40 -0
  7. aegismcp_security-3.1.0/src/aegismcp/__main__.py +5 -0
  8. aegismcp_security-3.1.0/src/aegismcp/ast_scanner.py +416 -0
  9. aegismcp_security-3.1.0/src/aegismcp/cli.py +508 -0
  10. aegismcp_security-3.1.0/src/aegismcp/config.py +117 -0
  11. aegismcp_security-3.1.0/src/aegismcp/cross_server.py +253 -0
  12. aegismcp_security-3.1.0/src/aegismcp/discovery.py +140 -0
  13. aegismcp_security-3.1.0/src/aegismcp/html_report.py +1011 -0
  14. aegismcp_security-3.1.0/src/aegismcp/inspector.py +478 -0
  15. aegismcp_security-3.1.0/src/aegismcp/js_scanner.py +90 -0
  16. aegismcp_security-3.1.0/src/aegismcp/lockfile.py +303 -0
  17. aegismcp_security-3.1.0/src/aegismcp/normalizer.py +367 -0
  18. aegismcp_security-3.1.0/src/aegismcp/proxy.py +851 -0
  19. aegismcp_security-3.1.0/src/aegismcp/reporter.py +267 -0
  20. aegismcp_security-3.1.0/src/aegismcp/rules/__init__.py +11 -0
  21. aegismcp_security-3.1.0/src/aegismcp/rules/builtins/__init__.py +35 -0
  22. aegismcp_security-3.1.0/src/aegismcp/rules/builtins/ast_rules.py +23 -0
  23. aegismcp_security-3.1.0/src/aegismcp/rules/builtins/config_rules.py +395 -0
  24. aegismcp_security-3.1.0/src/aegismcp/rules/builtins/cross_rules.py +122 -0
  25. aegismcp_security-3.1.0/src/aegismcp/rules/builtins/proxy_rules.py +289 -0
  26. aegismcp_security-3.1.0/src/aegismcp/rules/registry.py +70 -0
  27. aegismcp_security-3.1.0/src/aegismcp/rules_core.py +74 -0
  28. aegismcp_security-3.1.0/src/aegismcp/sarif.py +44 -0
  29. aegismcp_security-3.1.0/src/aegismcp/scanner.py +166 -0
  30. aegismcp_security-3.1.0/src/aegismcp/scoring.py +323 -0
  31. aegismcp_security-3.1.0/src/aegismcp_security.egg-info/PKG-INFO +572 -0
  32. aegismcp_security-3.1.0/src/aegismcp_security.egg-info/SOURCES.txt +39 -0
  33. aegismcp_security-3.1.0/src/aegismcp_security.egg-info/dependency_links.txt +1 -0
  34. aegismcp_security-3.1.0/src/aegismcp_security.egg-info/entry_points.txt +2 -0
  35. aegismcp_security-3.1.0/src/aegismcp_security.egg-info/requires.txt +8 -0
  36. aegismcp_security-3.1.0/src/aegismcp_security.egg-info/top_level.txt +1 -0
  37. aegismcp_security-3.1.0/tests/test_adversarial.py +935 -0
  38. aegismcp_security-3.1.0/tests/test_ast_scanner.py +303 -0
  39. aegismcp_security-3.1.0/tests/test_lock_verify.py +116 -0
  40. aegismcp_security-3.1.0/tests/test_scan.py +155 -0
  41. aegismcp_security-3.1.0/tests/test_stress_v3.py +1205 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 cyberlynxxx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,572 @@
1
+ Metadata-Version: 2.4
2
+ Name: aegismcp-security
3
+ Version: 3.1.0
4
+ Summary: Active MCP Security Engine & Runtime Firewall — live introspection, runtime proxy, cross-server rules, executive reporting, Python/JS taint tracking.
5
+ License: MIT
6
+ Project-URL: Homepage, https://github.com/cyberlynxxx/aegismcp
7
+ Project-URL: Repository, https://github.com/cyberlynxxx/aegismcp
8
+ Project-URL: Issues, https://github.com/cyberlynxxx/aegismcp/issues
9
+ Keywords: mcp,security,model-context-protocol,sarif,static-analysis,ai-security,runtime-protection,proxy,taint-tracking,codeql
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Information Technology
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Security
20
+ Classifier: Topic :: Software Development :: Quality Assurance
21
+ Classifier: Topic :: Software Development :: Testing
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: pyyaml>=6.0
26
+ Requires-Dist: httpx>=0.27
27
+ Requires-Dist: aiohttp>=3.9
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=7.0; extra == "dev"
30
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
31
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ <picture>
35
+ <source media="(prefers-color-scheme: dark)" srcset="./assets/banner-dark.svg">
36
+ <img alt="AegisMCP - Active MCP Security Engine & Runtime Firewall" src="./assets/banner-light.svg" width="520">
37
+ </picture>
38
+
39
+ <p align="center">
40
+ <strong>An Active MCP Security Engine & Runtime Firewall — live introspection, runtime proxy, cross-server rules, executive reporting.</strong>
41
+ </p>
42
+
43
+ <p align="center">
44
+ <a href="https://github.com/cyberlynxxx/aegismcp/actions/workflows/ci.yml">
45
+ <img alt="CI" src="https://github.com/cyberlynxxx/aegismcp/actions/workflows/ci.yml/badge.svg">
46
+ </a>
47
+ <a href="https://github.com/cyberlynxxx/aegismcp/releases/latest">
48
+ <img alt="Latest Release" src="https://img.shields.io/github/v/release/cyberlynxxx/aegismcp?color=brightgreen">
49
+ </a>
50
+ <a href="LICENSE">
51
+ <img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-blue.svg">
52
+ </a>
53
+ <a href="https://www.python.org/downloads/">
54
+ <img alt="Python 3.10+" src="https://img.shields.io/badge/python-3.10%2B-blue.svg">
55
+ </a>
56
+ <a href="https://pypi.org/project/aegismcp/">
57
+ <img alt="PyPI" src="https://img.shields.io/pypi/v/aegismcp?color=blue">
58
+ </a>
59
+ </p>
60
+
61
+ <p align="center">
62
+ <a href="#features">Features</a> ·
63
+ <a href="#quick-start">Quick Start</a> ·
64
+ <a href="#-live-introspection-inspect">Live Inspect</a> ·
65
+ <a href="#-runtime-proxy-firewall-proxy">Runtime Proxy</a> ·
66
+ <a href="#-html-reports">HTML Reports</a> ·
67
+ <a href="#benchmarks">Benchmarks</a> ·
68
+ <a href="https://github.com/cyberlynxxx/aegismcp/releases">Releases</a>
69
+ </p>
70
+
71
+ <p align="center">
72
+ <a href="#features">Features</a> ·
73
+ <a href="#quick-start">Quick Start</a> ·
74
+ <a href="#-live-introspection-inspect">Live Inspect</a> ·
75
+ <a href="#-runtime-proxy-firewall-proxy">Runtime Proxy</a> ·
76
+ <a href="#-html-reports">HTML Reports</a> ·
77
+ <a href="https://github.com/cyberlynxxx/aegismcp/releases">Releases</a>
78
+ </p>
79
+
80
+ ---
81
+
82
+ ## What It Detects
83
+
84
+ ### Built-in Rules (MCP Config Files)
85
+
86
+ | Rule ID | Severity | Description |
87
+ | :--- | :--- | :--- |
88
+ | `AMCP001` | CRITICAL | Direct shell execution (`bash`, `sh`, `cmd`, `powershell`) |
89
+ | `AMCP002` | MEDIUM | Unpinned `npx` packages (supply-chain risk) |
90
+ | `AMCP003` | HIGH | Overly broad or sensitive filesystem paths (`/`, `.ssh`, `.env`) |
91
+ | `AMCP004` | CRITICAL | Hardcoded API keys and tokens in `env` |
92
+ | `AMCP005` | CRITICAL | Tool poisoning & indirect prompt injection patterns |
93
+ | `AMCP006` | MEDIUM | Abnormally long tool descriptions used to hide payloads |
94
+ | `AMCP007` | CRITICAL | Invisible Unicode character smuggling (zero-width, bidi, tags) |
95
+ | `AMCP008` | HIGH | High-entropy unknown secrets detected via Shannon entropy |
96
+
97
+ ### AST Rules (Python MCP Server Source)
98
+
99
+ | Rule ID | Severity | Description |
100
+ | :--- | :--- | :--- |
101
+ | `AMCP101` | HIGH / CRITICAL | Command injection (`subprocess`, `os.system`, `os.popen`) |
102
+ | `AMCP102` | CRITICAL | Dynamic code execution (`eval`, `exec`) |
103
+ | `AMCP103` | HIGH | SSRF — dynamic URLs in HTTP calls (`requests`, `httpx`, etc.) |
104
+ | `AMCP104` | HIGH | Path traversal — user-controlled file paths |
105
+ | `AMCP105` | CRITICAL | Insecure deserialization (`pickle.loads`, `yaml.load` without SafeLoader) |
106
+
107
+ ### Cross-Server Rules (Multi-Server Analysis)
108
+
109
+ | Rule ID | Severity | Description |
110
+ | :--- | :--- | :--- |
111
+ | `AMCP201` | HIGH | Tool shadowing — duplicate tool names across servers |
112
+ | `AMCP202` | MEDIUM | Schema drift — tool signatures changed between lockfile and live |
113
+ | `AMCP203` | MEDIUM | Over-permissive tool input schemas (unconstrained dangerous params) |
114
+
115
+ ### Runtime Proxy Rules (Active Firewall)
116
+
117
+ | Rule ID | Severity | Description |
118
+ | :--- | :--- | :--- |
119
+ | `AMCP301` | CRITICAL | Prompt injection in tool call arguments |
120
+ | `AMCP302` | HIGH | Command injection patterns in arguments |
121
+ | `AMCP303` | HIGH | Path traversal in arguments |
122
+ | `AMCP304` | HIGH | SSRF patterns in URL arguments |
123
+ | `AMCP305` | MEDIUM | Rate limit exceeded |
124
+ | `AMCP306` | MEDIUM | Suspicious argument patterns (entropy, encoding) |
125
+ | `AMCP307` | LOW | Tool call audit logging |
126
+ | `AMCP308` | CRITICAL | Fail-closed: blocked by default unless explicitly allowed |
127
+ | `AMCP309` | CRITICAL | Server-to-client response inspection (indirect prompt injection, secret leakage, invisible Unicode) |
128
+
129
+ ---
130
+
131
+ ## Features
132
+
133
+ ### 🔴 Live MCP Server Introspection (`inspect`)
134
+ **New in v3.0.0** — Connect to running MCP servers via stdio or HTTP/SSE and run real-time security checks:
135
+
136
+ ```bash
137
+ # Connect via stdio (spawn server)
138
+ aegismcp inspect --command "python server.py" --sarif live.sarif --fail-on HIGH
139
+
140
+ # Connect via HTTP/SSE
141
+ aegismcp inspect --url http://localhost:8000/mcp --html live-report.html
142
+
143
+ # Connect using platform config (Claude Desktop, Cursor, etc.)
144
+ aegismcp inspect --config-file ~/Library/Application\ Support/Claude/claude_desktop_config.json
145
+
146
+ # Create lockfile from live server tools
147
+ aegismcp inspect --command "python server.py" --lock-output live.lock.json
148
+ ```
149
+
150
+ **Real-time checks performed:**
151
+ - `AMCP005` Tool poisoning in live tool descriptions
152
+ - `AMCP006` Abnormally long descriptions hiding payloads
153
+ - `AMCP007` Invisible Unicode characters
154
+ - `AMCP201` Tool shadowing (duplicate names)
155
+ - `AMCP203` Over-permissive input schemas
156
+
157
+ ### 🛡️ Runtime MCP Security Proxy (`proxy`)
158
+ **New in v3.0.1** — A transparent MCP proxy/firewall that sits between clients and servers, enforcing security policies in real-time with bidirectional protection:
159
+
160
+ ```bash
161
+ # Run proxy between client and server (stdio)
162
+ aegismcp proxy --command "python server.py" --policy proxy-policy.yaml
163
+
164
+ # Run proxy with HTTP upstream
165
+ aegismcp proxy --url http://upstream:8000/mcp --port 8080
166
+
167
+ # Enable audit logging
168
+ aegismcp proxy --command "python server.py" --audit-log audit.log --fail-closed
169
+ ```
170
+
171
+ **Proxy capabilities:**
172
+ - **Prompt injection detection** (AMCP301/AMCP309) — Blocks hidden LLM directives in arguments and responses
173
+ - **Anti-evasion normalizer** — Multi-stage URL/Base64/Hex decoding, Unicode NFKC normalization
174
+ - **Weighted scoring engine** — STRICT/BALANCED modes with configurable thresholds via policy
175
+ - **Command injection prevention** (AMCP302) — Detects shell metacharacters, command substitution
176
+ - **Path traversal blocking** (AMCP303) — Stops `../`, absolute paths, directory traversal
177
+ - **SSRF protection** (AMCP304) — Blocks private/internal IPs, localhost, metadata endpoints, alternative formats
178
+ - **Rate limiting** (AMCP305) — Configurable requests/second per client
179
+ - **Audit logging** (AMCP307) — JSONL structured logs for SIEM integration
180
+ - **Fail-closed defaults** (AMCP308) — Blocks unknown tools unless explicitly allowed
181
+ - **Server-to-client response inspection** (AMCP309) — Detects indirect prompt injection, secret leakage, invisible Unicode in tool results
182
+
183
+ ### 🔒 Rug-Pull Protection (`lock` / `verify`) — Enhanced
184
+ Lockfiles store SHA-256 hashes of server configs **and live tool definitions**.
185
+
186
+ ```bash
187
+ # Create lockfile from static config (v2.x compatible)
188
+ aegismcp lock samples/vulnerable_mcp.json -o aegismcp.lock.json
189
+
190
+ # Create lockfile from LIVE server (NEW v3.0.0)
191
+ aegismcp lock --live --command "python server.py" -o aegismcp.lock.json
192
+ aegismcp lock --live --url http://localhost:8000/mcp -o aegismcp.lock.json
193
+
194
+ # Verify static config against lockfile
195
+ aegismcp verify samples/vulnerable_mcp.json -l aegismcp.lock.json
196
+
197
+ # Verify LIVE server against lockfile (NEW v3.0.0) — catches runtime rug-pulls!
198
+ aegismcp verify --live --command "python server.py" -l aegismcp.lock.json
199
+ aegismcp verify --live --url http://localhost:8000/mcp -l aegismcp.lock.json
200
+ ```
201
+
202
+ ### 🐍 Python AST Scanning (`ast-scan`)
203
+ Static analysis of Python MCP server source code for runtime vulnerabilities:
204
+
205
+ ```bash
206
+ # Excludes test files by default (tests/, test_*.py, *_test.py)
207
+ aegismcp ast-scan path/to/server.py --sarif ast-report.sarif --fail-on HIGH
208
+
209
+ # Include test files explicitly
210
+ aegismcp ast-scan path/to/server.py --include-tests --fail-on HIGH
211
+
212
+ # Export HTML report
213
+ aegismcp ast-scan path/to/server.py --html ast-report.html
214
+ ```
215
+
216
+ ### 🌐 Cross-Server Analysis
217
+ Scan multiple MCP configs together to detect cross-server risks:
218
+
219
+ ```bash
220
+ # Scan directory of configs for shadowing and drift
221
+ aegismcp scan configs/ --cross-server --sarif cross.sarif
222
+ ```
223
+
224
+ ### 📦 SARIF Export & CI/CD
225
+ All scan commands support SARIF 2.1.0 output:
226
+
227
+ ```bash
228
+ aegismcp scan samples/vulnerable_mcp.json --sarif report.sarif --fail-on HIGH
229
+ aegismcp ast-scan server.py --sarif ast.sarif --fail-on CRITICAL
230
+ aegismcp inspect --command "python server.py" --sarif live.sarif
231
+ aegismcp verify --live --command "python server.py" -l lock.json --sarif verify.sarif
232
+ ```
233
+
234
+ Use `--fail-on LEVEL` (LOW, MEDIUM, HIGH, CRITICAL) to gate CI pipelines.
235
+
236
+ ### 📊 HTML Executive Reports
237
+ **New in v3.0.0** — Beautiful, interactive HTML reports with dark/light themes:
238
+
239
+ ```bash
240
+ aegismcp scan samples/vulnerable_mcp.json --html report.html
241
+ aegismcp ast-scan server.py --html ast-report.html
242
+ aegismcp inspect --command "python server.py" --html live-report.html
243
+ ```
244
+
245
+ Features: severity filters, searchable findings, collapsible details, print-optimized CSS, copy-to-clipboard SARIF/JSON.
246
+
247
+ ### 🔌 Extensible RuleRegistry
248
+ Built-in rules + custom regex rules loaded from config. No code changes needed for new patterns.
249
+
250
+ ### 🪟 Windows Compatible
251
+ All CLI output uses `[OK]`/`[FAIL]` markers (no Unicode symbols), colored output works in modern terminals.
252
+
253
+ ---
254
+
255
+ ## Quick Start
256
+
257
+ ```bash
258
+ # Install from GitHub
259
+ pip install git+https://github.com/cyberlynxxx/aegismcp.git
260
+
261
+ # Or from source (editable)
262
+ git clone https://github.com/cyberlynxxx/aegismcp
263
+ cd aegismcp
264
+ pip install -e .
265
+
266
+ # With dev dependencies (for testing)
267
+ pip install -e ".[dev]"
268
+ ```
269
+
270
+ ### Scan your MCP configs
271
+ ```bash
272
+ # Auto-discover platform configs (Claude Desktop, Cursor, Windsurf, VS Code)
273
+ aegismcp scan --auto
274
+
275
+ # Scan a specific config file
276
+ aegismcp scan samples/vulnerable_mcp.json
277
+
278
+ # Export SARIF for GitHub Code Scanning
279
+ aegismcp scan samples/vulnerable_mcp.json --sarif report.sarif --fail-on HIGH
280
+
281
+ # Cross-server analysis
282
+ aegismcp scan configs/ --cross-server --html cross-report.html
283
+ ```
284
+
285
+ ### Live introspection (v3.0.0)
286
+ ```bash
287
+ # Inspect a running server via stdio
288
+ aegismcp inspect --command "python server.py" --fail-on HIGH --html live.html
289
+
290
+ # Inspect via HTTP/SSE
291
+ aegismcp inspect --url http://localhost:8000/mcp --sarif live.sarif
292
+
293
+ # Create lockfile from live server
294
+ aegismcp inspect --command "python server.py" --lock-output live.lock.json
295
+ ```
296
+
297
+ ### Runtime proxy (v3.0.0)
298
+ ```bash
299
+ # Proxy stdio server with security enforcement
300
+ aegismcp proxy --command "python server.py" --policy proxy-policy.yaml --audit-log audit.log
301
+
302
+ # Proxy HTTP upstream
303
+ aegismcp proxy --url http://upstream:8000/mcp --port 8080 --fail-closed
304
+ ```
305
+
306
+ ### Lock & verify (rug-pull protection)
307
+ ```bash
308
+ # Create lockfile from static config
309
+ aegismcp lock samples/vulnerable_mcp.json -o aegismcp.lock.json
310
+
311
+ # Create lockfile from LIVE server (catches runtime tool definitions)
312
+ aegismcp lock --live --command "python server.py" -o aegismcp.lock.json
313
+
314
+ # Verify static config
315
+ aegismcp verify samples/vulnerable_mcp.json -l aegismcp.lock.json
316
+
317
+ # Verify LIVE server (detects runtime rug-pulls!)
318
+ aegismcp verify --live --command "python server.py" -l aegismcp.lock.json
319
+ ```
320
+
321
+ ### Scan Python MCP server source
322
+ ```bash
323
+ # Scan for command injection, SSRF, path traversal, insecure deserialization
324
+ aegismcp ast-scan path/to/server.py --fail-on HIGH --html ast-report.html
325
+
326
+ # Include test files if needed
327
+ aegismcp ast-scan path/to/server.py --include-tests --fail-on HIGH
328
+ ```
329
+
330
+ ---
331
+
332
+ ## CLI Reference
333
+
334
+ ```bash
335
+ aegismcp [--config CONFIG] [--no-color] <COMMAND>
336
+ ```
337
+
338
+ | Command | Description |
339
+ | :--- | :--- |
340
+ | `scan` | Scan MCP config file(s) or directory |
341
+ | `inspect` | **v3.0.0** Live MCP server introspection via stdio/HTTP |
342
+ | `proxy` | **v3.0.0** Runtime MCP security proxy/firewall |
343
+ | `lock` | Create lockfile from MCP config or live server |
344
+ | `verify` | Verify MCP config or live server against lockfile |
345
+ | `ast-scan` | Scan Python MCP server source code for vulnerabilities |
346
+
347
+ ### `scan`
348
+ ```bash
349
+ aegismcp scan [TARGET] [--auto] [--cross-server] [--sarif FILE] [--html FILE] [--fail-on LEVEL] [--no-auto-discover]
350
+ ```
351
+
352
+ | Option | Description |
353
+ | :--- | :--- |
354
+ | `TARGET` | Path to MCP config file or directory (optional if `--auto` or `auto_discover: true` in config) |
355
+ | `--auto` | Auto-discover platform MCP configs |
356
+ | `--cross-server` | Enable cross-server analysis (shadowing, drift) |
357
+ | `--sarif FILE` | Export SARIF report |
358
+ | `--html FILE` | Export HTML executive report |
359
+ | `--fail-on LEVEL` | Exit with error if findings ≥ LEVEL (LOW/MEDIUM/HIGH/CRITICAL) |
360
+ | `--no-auto-discover` | Disable platform auto-discovery |
361
+
362
+ ### `inspect` (v3.0.0)
363
+ ```bash
364
+ aegismcp inspect [--command CMD] [--url URL] [--config-file FILE] [--sarif FILE] [--html FILE] [--lock-output FILE] [--fail-on LEVEL] [--timeout SEC]
365
+ ```
366
+
367
+ | Option | Description |
368
+ | :--- | :--- |
369
+ | `--command CMD` | Command to spawn MCP server (stdio) |
370
+ | `--url URL` | HTTP/SSE endpoint for MCP server |
371
+ | `--config-file FILE` | Path to platform MCP config file (Claude Desktop, Cursor, etc.) |
372
+ | `--sarif FILE` | Export SARIF report |
373
+ | `--html FILE` | Export HTML executive report |
374
+ | `--lock-output FILE` | Create lockfile from live server tools |
375
+ | `--fail-on LEVEL` | Exit with error if findings ≥ LEVEL |
376
+ | `--timeout SEC` | Connection timeout (default: 10s) |
377
+
378
+ ### `proxy` (v3.0.1)
379
+ ```bash
380
+ aegismcp proxy [--command CMD] [--url URL] [--port PORT] [--policy FILE] [--audit-log FILE] [--fail-closed] [--rate-limit RPS]
381
+ ```
382
+
383
+ | Option | Description |
384
+ | :--- | :--- |
385
+ | `--command CMD` | Command to spawn upstream MCP server (stdio) |
386
+ | `--url URL` | HTTP/SSE upstream MCP server |
387
+ | `--port PORT` | Local port for HTTP proxy mode (default: 8080) |
388
+ | `--policy FILE` | Path to proxy policy YAML file |
389
+ | `--audit-log FILE` | Path to audit log (JSONL format) |
390
+ | `--fail-closed` | Block unknown tools by default |
391
+ | `--rate-limit RPS` | Requests per second limit (default: 100) |
392
+
393
+ #### Proxy Policy Options (proxy-policy.yaml)
394
+
395
+ | Setting | Description |
396
+ | :--- | :--- |
397
+ | `prompt_injection_mode` | `balanced` (default) or `strict` - weighted scoring threshold |
398
+ | `blocked_response_patterns` | List of regex patterns that trigger response blocking |
399
+ | `max_decode_depth` | Maximum iterations for normalization decoding (default: 5) |
400
+
401
+ ### `lock`
402
+ ```bash
403
+ aegismcp lock <CONFIG_FILE> [-o OUTPUT] [--live] [--command CMD] [--url URL]
404
+ ```
405
+
406
+ | Option | Description |
407
+ | :--- | :--- |
408
+ | `CONFIG_FILE` | Path to MCP config file (not needed with `--live`) |
409
+ | `-o, --output` | Output lockfile path (default: `./aegismcp.lock.json`) |
410
+ | `--live` | Create lockfile from live server instead of static config |
411
+ | `--command CMD` | Spawn server command for live mode |
412
+ | `--url URL` | HTTP/SSE URL for live mode |
413
+
414
+ ### `verify`
415
+ ```bash
416
+ aegismcp verify <CONFIG_FILE> [-l LOCKFILE] [--live] [--command CMD] [--url URL] [--sarif FILE]
417
+ ```
418
+
419
+ | Option | Description |
420
+ | :--- | :--- |
421
+ | `CONFIG_FILE` | Path to MCP config file (not needed with `--live`) |
422
+ | `-l, --lockfile` | Path to lockfile (default: `./aegismcp.lock.json`) |
423
+ | `--live` | Verify live server instead of static config |
424
+ | `--command CMD` | Spawn server command for live mode |
425
+ | `--url URL` | HTTP/SSE URL for live mode |
426
+ | `--sarif FILE` | Export SARIF report |
427
+
428
+ ### `ast-scan`
429
+ ```bash
430
+ aegismcp ast-scan <TARGET> [--sarif FILE] [--html FILE] [--fail-on LEVEL] [--include-tests]
431
+ ```
432
+
433
+ | Option | Description |
434
+ | :--- | :--- |
435
+ | `TARGET` | Path to Python file or directory |
436
+ | `--sarif FILE` | Export SARIF report |
437
+ | `--html FILE` | Export HTML executive report |
438
+ | `--fail-on LEVEL` | Exit with error if findings ≥ LEVEL (default: HIGH) |
439
+ | `--include-tests` | Include test files/directories (`tests/`, `test_*.py`, `*_test.py`) |
440
+
441
+ ---
442
+
443
+ ## Proxy Policy Configuration
444
+
445
+ Create a `proxy-policy.yaml` to customize runtime enforcement:
446
+
447
+ ```yaml
448
+ # proxy-policy.yaml
449
+ fail_closed: true # Block unknown tools by default
450
+ prompt_injection_mode: "balanced" # STRICT or BALANCED - weighted scoring mode
451
+ allowed_tools: # Explicitly allowlisted tools
452
+ - "safe_read"
453
+ - "safe_write"
454
+ rate_limit: 50 # Requests per second per client
455
+ block_patterns: # Custom block patterns
456
+ - pattern: "internal\\.api\\.com"
457
+ message: "Internal API access blocked"
458
+ audit_log: "audit.log" # JSONL audit log path
459
+ log_level: "INFO" # DEBUG, INFO, WARNING, ERROR
460
+ ```
461
+
462
+ ---
463
+
464
+ ## Example Output
465
+
466
+ ```
467
+ [CRITICAL] AMCP001 - Direct Shell Execution Allowed
468
+ Location: samples/vulnerable_mcp.json:mcpServers.unsafe-shell
469
+ Detail: Server 'unsafe-shell' invokes shell 'bash' directly.
470
+ Fix: Replace shell wrappers with a dedicated, scoped MCP server binary.
471
+
472
+ [HIGH] AMCP103 - Potential SSRF (Server-Side Request Forgery)
473
+ File: server.py:33:15
474
+ Detail: HTTP request with dynamic URL detected (requests.get)
475
+ Fix: Validate URLs against allowlist, block private/internal IPs
476
+
477
+ [CRITICAL] AMCP301 - Prompt Injection Detected (Runtime Proxy)
478
+ Tool: dangerous_tool
479
+ Argument: command="rm -rf / ; ignore previous instructions"
480
+ Action: BLOCKED
481
+
482
+ Summary: 9 findings (6 CRITICAL, 2 HIGH, 1 MEDIUM) in 1 file(s)
483
+ ```
484
+
485
+ ---
486
+
487
+ ## Benchmarks
488
+
489
+ AegisMCP v3.1.0 includes a comprehensive benchmarking suite (`scripts/benchmark.py`) measuring True Positive Rate (TPR), False Positive Rate (FPR), and latency.
490
+
491
+ | Component | Metric | Result | Notes |
492
+ | :--- | :--- | :--- | :--- |
493
+ | **AST Scanner (Python)** | TPR | 100% (54/54) | All injected vulnerabilities detected |
494
+ | | FPR | 0% (0/38) | Zero false positives on clean code |
495
+ | **Runtime Proxy** | Latency P99 | 3ms | 500 calls, stdio transport |
496
+ | | Throughput | ~300 req/s | Single-threaded, no rate limiting |
497
+ | **Cross-Server Analysis** | Tool Shadowing | 100% detection | Duplicate names across 1000 tools |
498
+ | | Permissive Schemas | 100% detection | Unconstrained dangerous params |
499
+ | **Config Scanner** | TPR (balanced) | ~30% | Rules target tool descriptions/env, not raw payloads |
500
+ | | TPR (strict) | ~30% | Same limitation by design |
501
+
502
+ > **Note**: Config scanner TPR appears lower because rules (AMCP005-AMCP008) are designed to analyze *tool descriptions* and *environment variables* in MCP config files, not arbitrary payload strings. The benchmark test feeds raw attack payloads directly, which is not the intended threat model.
503
+
504
+ ### Running Benchmarks
505
+
506
+ ```bash
507
+ # Run full benchmark suite
508
+ python scripts/benchmark.py
509
+
510
+ # Run specific benchmarks
511
+ python -m pytest tests/test_stress_v3.py -v -k "benchmark"
512
+ ```
513
+
514
+ ---
515
+
516
+ ## Project Structure
517
+
518
+ ```
519
+ aegismcp/
520
+ ├── LICENSE # MIT License
521
+ ├── aegismcp.yaml # Example policy config
522
+ ├── proxy-policy.yaml # Example proxy policy
523
+ ├── assets/
524
+ │ ├── banner-dark.svg # Dark mode banner
525
+ │ └── banner-light.svg # Light mode banner
526
+ ├── samples/
527
+ │ ├── vulnerable_mcp.json # Test config with all rule triggers
528
+ │ └── test_server.py # Test Python server with AST vulnerabilities
529
+ ├── tests/ # Pytest test suite
530
+ │ ├── conftest.py
531
+ │ ├── test_scan.py
532
+ │ ├── test_lock_verify.py
533
+ │ ├── test_ast_scanner.py
534
+ │ ├── test_inspector.py
535
+ │ ├── test_proxy.py
536
+ │ ├── test_reporter.py
537
+ │ └── test_stress_v3.py # v3.0.0 stress/e2e tests
538
+ ├── .github/workflows/
539
+ │ └── ci.yml # GitHub Actions CI (Linux + Windows, Python 3.10/3.12)
540
+ ├── src/aegismcp/
541
+ │ ├── __main__.py # CLI entry point
542
+ │ ├── cli.py # Command implementations
543
+ │ ├── config.py # aegismcp.yaml loader
544
+ │ ├── discovery.py # Cross-platform auto-discovery
545
+ │ ├── lockfile.py # SHA-256 lockfile (rug-pull protection)
546
+ │ ├── ast_scanner.py # AST visitor for Python vulnerabilities
547
+ │ ├── scanner.py # Main scanner engine
548
+ │ ├── sarif.py # SARIF 2.1.0 exporter
549
+ │ ├── rules_core.py # Finding dataclass
550
+ │ ├── inspector.py # Live MCP introspection (JSON-RPC 2.0)
551
+ │ ├── proxy.py # Runtime MCP security proxy
552
+ │ ├── reporter.py # HTML/SARIF/Console reporters
553
+ │ ├── cross_server.py # Cross-server analysis (shadowing, drift)
554
+ │ ├── html_report.py # HTML report generator
555
+ │ └── rules/
556
+ │ ├── __init__.py # Auto-registers built-in rules
557
+ │ ├── registry.py # RuleRegistry class
558
+ │ └── builtins/
559
+ │ └── __init__.py # AMCP001-AMCP008, AMCP101-AMCP105, AMCP201-AMCP203, AMCP301-AMCP308
560
+ ```
561
+
562
+ ---
563
+
564
+ ## License
565
+
566
+ MIT License — see [LICENSE](LICENSE) for details.
567
+
568
+ ---
569
+
570
+ ## Contributing
571
+
572
+ Issues and PRs welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.