mcpthreat-scan 0.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 (120) hide show
  1. mcpthreat_scan-0.1.0/LICENSE +201 -0
  2. mcpthreat_scan-0.1.0/PKG-INFO +363 -0
  3. mcpthreat_scan-0.1.0/README.md +335 -0
  4. mcpthreat_scan-0.1.0/pyproject.toml +50 -0
  5. mcpthreat_scan-0.1.0/requirements.txt +20 -0
  6. mcpthreat_scan-0.1.0/setup.cfg +4 -0
  7. mcpthreat_scan-0.1.0/src/mcpthreat_scan/__init__.py +1 -0
  8. mcpthreat_scan-0.1.0/src/mcpthreat_scan/analyzers/__init__.py +1 -0
  9. mcpthreat_scan-0.1.0/src/mcpthreat_scan/analyzers/ai_review.py +122 -0
  10. mcpthreat_scan-0.1.0/src/mcpthreat_scan/analyzers/capability.py +59 -0
  11. mcpthreat_scan-0.1.0/src/mcpthreat_scan/analyzers/dependencies.py +198 -0
  12. mcpthreat_scan-0.1.0/src/mcpthreat_scan/analyzers/manifest.py +94 -0
  13. mcpthreat_scan-0.1.0/src/mcpthreat_scan/analyzers/semgrep.py +101 -0
  14. mcpthreat_scan-0.1.0/src/mcpthreat_scan/analyzers/typosquat.py +126 -0
  15. mcpthreat_scan-0.1.0/src/mcpthreat_scan/cli/__init__.py +1 -0
  16. mcpthreat_scan-0.1.0/src/mcpthreat_scan/cli/main.py +166 -0
  17. mcpthreat_scan-0.1.0/src/mcpthreat_scan/core/__init__.py +1 -0
  18. mcpthreat_scan-0.1.0/src/mcpthreat_scan/core/exceptions.py +5 -0
  19. mcpthreat_scan-0.1.0/src/mcpthreat_scan/core/models.py +58 -0
  20. mcpthreat_scan-0.1.0/src/mcpthreat_scan/core/orchestrator.py +780 -0
  21. mcpthreat_scan-0.1.0/src/mcpthreat_scan/diff/__init__.py +1 -0
  22. mcpthreat_scan-0.1.0/src/mcpthreat_scan/diff/rugpull.py +108 -0
  23. mcpthreat_scan-0.1.0/src/mcpthreat_scan/diff/tool_schema.py +217 -0
  24. mcpthreat_scan-0.1.0/src/mcpthreat_scan/diff/ts_tool_schema.py +360 -0
  25. mcpthreat_scan-0.1.0/src/mcpthreat_scan/policy/__init__.py +1 -0
  26. mcpthreat_scan-0.1.0/src/mcpthreat_scan/policy/ignore.py +66 -0
  27. mcpthreat_scan-0.1.0/src/mcpthreat_scan/policy/reputation.py +83 -0
  28. mcpthreat_scan-0.1.0/src/mcpthreat_scan/reporting/__init__.py +1 -0
  29. mcpthreat_scan-0.1.0/src/mcpthreat_scan/reporting/json.py +10 -0
  30. mcpthreat_scan-0.1.0/src/mcpthreat_scan/reporting/sarif.py +70 -0
  31. mcpthreat_scan-0.1.0/src/mcpthreat_scan/reporting/text.py +45 -0
  32. mcpthreat_scan-0.1.0/src/mcpthreat_scan/resources/known_mcp_servers.json +430 -0
  33. mcpthreat_scan-0.1.0/src/mcpthreat_scan/resources/rules/capability_mismatch.yaml +89 -0
  34. mcpthreat_scan-0.1.0/src/mcpthreat_scan/resources/rules/command_injection.yaml +41 -0
  35. mcpthreat_scan-0.1.0/src/mcpthreat_scan/resources/rules/command_injection_node.yaml +60 -0
  36. mcpthreat_scan-0.1.0/src/mcpthreat_scan/resources/rules/hardcoded_secret.yaml +34 -0
  37. mcpthreat_scan-0.1.0/src/mcpthreat_scan/resources/rules/hardcoded_secret_node.yaml +51 -0
  38. mcpthreat_scan-0.1.0/src/mcpthreat_scan/resources/rules/header_leak.yaml +32 -0
  39. mcpthreat_scan-0.1.0/src/mcpthreat_scan/resources/rules/header_leak_node.yaml +31 -0
  40. mcpthreat_scan-0.1.0/src/mcpthreat_scan/resources/rules/missing_audit.yaml +56 -0
  41. mcpthreat_scan-0.1.0/src/mcpthreat_scan/resources/rules/tool_poisoning.yaml +41 -0
  42. mcpthreat_scan-0.1.0/src/mcpthreat_scan/resources/rules/tool_poisoning_node.yaml +81 -0
  43. mcpthreat_scan-0.1.0/src/mcpthreat_scan/resources/rules/tool_poisoning_output.yaml +61 -0
  44. mcpthreat_scan-0.1.0/src/mcpthreat_scan/resources/rules/unscoped_environ.yaml +49 -0
  45. mcpthreat_scan-0.1.0/src/mcpthreat_scan/resources/rules/unscoped_environ_node.yaml +39 -0
  46. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/__init__.py +1 -0
  47. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/app.py +52 -0
  48. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/app.tcss +278 -0
  49. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/banner.py +75 -0
  50. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/display.py +65 -0
  51. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/logo.py +84 -0
  52. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/screens/__init__.py +0 -0
  53. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/screens/comparison.py +164 -0
  54. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/screens/confirm.py +47 -0
  55. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/screens/diff_wizard.py +112 -0
  56. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/screens/export.py +96 -0
  57. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/screens/ignore_manager.py +1 -0
  58. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/screens/main_menu.py +156 -0
  59. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/screens/reputation_manager.py +1 -0
  60. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/screens/results.py +194 -0
  61. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/screens/running.py +175 -0
  62. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/screens/scan_wizard.py +174 -0
  63. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/screens/settings.py +114 -0
  64. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/screens/setup.py +53 -0
  65. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/screens/summary.py +139 -0
  66. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/screens/trust.py +228 -0
  67. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/state.py +44 -0
  68. mcpthreat_scan-0.1.0/src/mcpthreat_scan/tui/theme.py +48 -0
  69. mcpthreat_scan-0.1.0/src/mcpthreat_scan.egg-info/PKG-INFO +363 -0
  70. mcpthreat_scan-0.1.0/src/mcpthreat_scan.egg-info/SOURCES.txt +118 -0
  71. mcpthreat_scan-0.1.0/src/mcpthreat_scan.egg-info/dependency_links.txt +1 -0
  72. mcpthreat_scan-0.1.0/src/mcpthreat_scan.egg-info/entry_points.txt +2 -0
  73. mcpthreat_scan-0.1.0/src/mcpthreat_scan.egg-info/requires.txt +11 -0
  74. mcpthreat_scan-0.1.0/src/mcpthreat_scan.egg-info/top_level.txt +1 -0
  75. mcpthreat_scan-0.1.0/tests/test_ai_review.py +76 -0
  76. mcpthreat_scan-0.1.0/tests/test_architecture_rules.py +396 -0
  77. mcpthreat_scan-0.1.0/tests/test_batch_scan.py +157 -0
  78. mcpthreat_scan-0.1.0/tests/test_benchmark_eval.py +195 -0
  79. mcpthreat_scan-0.1.0/tests/test_benchmark_separation.py +120 -0
  80. mcpthreat_scan-0.1.0/tests/test_capability.py +88 -0
  81. mcpthreat_scan-0.1.0/tests/test_cli.py +292 -0
  82. mcpthreat_scan-0.1.0/tests/test_cli_diff_smoke.py +90 -0
  83. mcpthreat_scan-0.1.0/tests/test_cli_errors.py +97 -0
  84. mcpthreat_scan-0.1.0/tests/test_cli_output.py +95 -0
  85. mcpthreat_scan-0.1.0/tests/test_cli_parser.py +78 -0
  86. mcpthreat_scan-0.1.0/tests/test_cli_scan_smoke.py +123 -0
  87. mcpthreat_scan-0.1.0/tests/test_cli_target.py +102 -0
  88. mcpthreat_scan-0.1.0/tests/test_dependency_check.py +111 -0
  89. mcpthreat_scan-0.1.0/tests/test_discovery.py +180 -0
  90. mcpthreat_scan-0.1.0/tests/test_estimate_precision.py +85 -0
  91. mcpthreat_scan-0.1.0/tests/test_ignore.py +89 -0
  92. mcpthreat_scan-0.1.0/tests/test_import_graph.py +195 -0
  93. mcpthreat_scan-0.1.0/tests/test_manifest.py +229 -0
  94. mcpthreat_scan-0.1.0/tests/test_npm_dependencies.py +161 -0
  95. mcpthreat_scan-0.1.0/tests/test_orchestrator_stages.py +411 -0
  96. mcpthreat_scan-0.1.0/tests/test_policy_store_api.py +149 -0
  97. mcpthreat_scan-0.1.0/tests/test_report.py +498 -0
  98. mcpthreat_scan-0.1.0/tests/test_report_enrichment.py +198 -0
  99. mcpthreat_scan-0.1.0/tests/test_report_errors.py +121 -0
  100. mcpthreat_scan-0.1.0/tests/test_report_flow.py +168 -0
  101. mcpthreat_scan-0.1.0/tests/test_report_json_bytes.py +67 -0
  102. mcpthreat_scan-0.1.0/tests/test_reporting_json.py +72 -0
  103. mcpthreat_scan-0.1.0/tests/test_reporting_pure.py +54 -0
  104. mcpthreat_scan-0.1.0/tests/test_reporting_sarif.py +140 -0
  105. mcpthreat_scan-0.1.0/tests/test_reporting_text.py +92 -0
  106. mcpthreat_scan-0.1.0/tests/test_reputation.py +49 -0
  107. mcpthreat_scan-0.1.0/tests/test_resources.py +217 -0
  108. mcpthreat_scan-0.1.0/tests/test_rugpull_diff.py +142 -0
  109. mcpthreat_scan-0.1.0/tests/test_sample_findings.py +91 -0
  110. mcpthreat_scan-0.1.0/tests/test_semgrep_runner.py +109 -0
  111. mcpthreat_scan-0.1.0/tests/test_server_detection.py +71 -0
  112. mcpthreat_scan-0.1.0/tests/test_simplicity_guards.py +117 -0
  113. mcpthreat_scan-0.1.0/tests/test_tool_schema.py +166 -0
  114. mcpthreat_scan-0.1.0/tests/test_ts_tool_schema.py +398 -0
  115. mcpthreat_scan-0.1.0/tests/test_tui.py +604 -0
  116. mcpthreat_scan-0.1.0/tests/test_tui_logo.py +74 -0
  117. mcpthreat_scan-0.1.0/tests/test_tui_menu_navigation.py +194 -0
  118. mcpthreat_scan-0.1.0/tests/test_tui_screens.py +708 -0
  119. mcpthreat_scan-0.1.0/tests/test_tui_target.py +32 -0
  120. mcpthreat_scan-0.1.0/tests/test_typosquat_check.py +120 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,363 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcpthreat-scan
3
+ Version: 0.1.0
4
+ Summary: Static zero-execution security scanner for MCP server source code
5
+ Author: Taha Al-Faqih
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/0xtahaa/MCPThreat-Scan
8
+ Project-URL: Source, https://github.com/0xtahaa/MCPThreat-Scan
9
+ Project-URL: Issues, https://github.com/0xtahaa/MCPThreat-Scan/issues
10
+ Keywords: mcp,security,scanner,static-analysis,semgrep
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Topic :: Security
13
+ Classifier: Environment :: Console
14
+ Requires-Python: >=3.12
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: semgrep>=1.86.0
18
+ Requires-Dist: pip-audit>=2.10.0
19
+ Requires-Dist: openai>=1.0.0
20
+ Requires-Dist: python-dotenv>=1.0.0
21
+ Requires-Dist: textual>=8.2.0
22
+ Requires-Dist: pyfiglet>=1.0.4
23
+ Requires-Dist: tree-sitter>=0.25.0
24
+ Requires-Dist: tree-sitter-typescript>=0.23.2
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=8.3.0; extra == "dev"
27
+ Dynamic: license-file
28
+
29
+ # MCPThreat-Scan
30
+
31
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
32
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue.svg)](pyproject.toml)
33
+
34
+ **Check MCP servers for security flaws before you trust them — without ever running them.**
35
+
36
+ MCPThreat-Scan reads the source code of an MCP server (Python, TypeScript or JavaScript)
37
+ and reports risks such as hardcoded secrets, command injection and poisoned tool
38
+ descriptions. It is made for anyone who connects AI agents to third-party MCP servers
39
+ (individuals, developers and teams) and wants to know what a server can do before giving it
40
+ access to their data and tools. Because the scanned code is never executed, it is safe to
41
+ scan servers you do not trust yet. If you build MCP servers yourself, use it to check your
42
+ own code before a release.
43
+
44
+ ## Example
45
+
46
+ ```text
47
+ $ mcpthreat-scan scan benchmark/vulnerable/command_injection.py
48
+
49
+ benchmark\vulnerable\command_injection.py:
50
+ Line 9 [Command Injection] ERROR: Command Injection: A function parameter flows unchecked
51
+ into a shell command or eval/exec. ...
52
+
53
+ Summary: 8 of 9 OWASP MCP categories without findings.
54
+ Categories with findings: Command Injection
55
+ ```
56
+
57
+ Every finding shows the file, line, category, severity and a hint on how to fix it.
58
+
59
+ ## Features
60
+
61
+ - **Zero-execution:** the code is only read and parsed, never run, so it is safe to scan
62
+ servers you do not trust yet
63
+ - **9 OWASP MCP risk categories:** from hardcoded secrets and command injection to tool
64
+ poisoning and typosquatting
65
+ - **Rug-pull detection:** compare two versions of a server and see changed tools, parameters
66
+ and descriptions (`diff`)
67
+ - **Optional AI review** of tool-poisoning candidates (opt-in with `--ai-review`)
68
+ - **CI-ready:** text, JSON and SARIF output, and `--fail-on` to fail a build by severity
69
+ - **Interactive terminal UI** (`tui`)
70
+ - **Open benchmark** with known test cases, so you can check how the rules perform
71
+
72
+ ## Quick start
73
+
74
+ Requires Python 3.12+ and Git.
75
+
76
+ ```bash
77
+ git clone https://github.com/0xtahaa/MCPThreat-Scan.git
78
+ cd MCPThreat-Scan
79
+ python -m venv .venv
80
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
81
+ pip install -e .
82
+ ```
83
+
84
+ The commands below assume the virtual environment is active.
85
+
86
+ **Interactive interface (recommended to start):**
87
+
88
+ ```bash
89
+ mcpthreat-scan tui
90
+ ```
91
+
92
+ It guides you through choosing a target, running the scan and reading the findings.
93
+
94
+ **Command line:** scan a single file or a whole folder:
95
+
96
+ ```bash
97
+ mcpthreat-scan scan path/to/mcp_server.py
98
+ ```
99
+
100
+ Optional: for the AI review (`--ai-review`), store an `OPENAI_API_KEY` in a local `.env`
101
+ file. It is never committed (see `.gitignore`).
102
+
103
+ ### Set up with an AI assistant
104
+
105
+ Copy this prompt into Claude Code, Codex or a similar agent. It only installs the tool.
106
+
107
+ ```text
108
+ Set up MCPThreat-Scan for me. Only do the setup, do not scan anything.
109
+
110
+ 1. Check that Python 3.12+ and Git are installed. If not, tell me how to install them.
111
+ 2. Clone https://github.com/0xtahaa/MCPThreat-Scan.git, create a virtual environment
112
+ and run `pip install -e .`.
113
+ 3. Check the installation with: mcpthreat-scan --help
114
+ 4. Tell me how to start the interactive interface myself:
115
+ mcpthreat-scan tui
116
+
117
+ Show me each command before you run it.
118
+ ```
119
+
120
+ > **Run the scans yourself.** We recommend not letting an AI agent scan or read untrusted
121
+ > servers for you: scanned code can contain instructions aimed at AI agents, which is exactly
122
+ > what the *Tool Poisoning* check looks for. Use the interactive interface or the command line.
123
+
124
+ ## Usage
125
+
126
+ ### Scan
127
+
128
+ Scan a single file or a whole folder:
129
+
130
+ ```bash
131
+ mcpthreat-scan scan path/to/mcp_server.py
132
+ mcpthreat-scan scan path/to/project/
133
+ ```
134
+
135
+ The default output is readable text. Tool-poisoning findings are first reported as
136
+ *candidates*. With `--ai-review`, an OpenAI model reviews each candidate and confirms or
137
+ dismisses it:
138
+
139
+ ```bash
140
+ mcpthreat-scan scan path/to/mcp_server.py --ai-review
141
+ ```
142
+
143
+ This needs an `OPENAI_API_KEY`. Without one, the scan does not abort and the candidate simply
144
+ stays unconfirmed.
145
+
146
+ ### Compare two versions (rug-pull detection)
147
+
148
+ A server that was harmless in version 1 can turn malicious in version 2. Compare two versions
149
+ of the same file to see what changed in tool names, parameters, descriptions and hidden
150
+ behavior:
151
+
152
+ ```bash
153
+ mcpthreat-scan diff server_v1.py server_v2.py
154
+ ```
155
+
156
+ ### Output formats and CI
157
+
158
+ | Option | Effect |
159
+ |---|---|
160
+ | `--format text` | Readable text (default) |
161
+ | `--format json` | Machine-readable JSON |
162
+ | `--format sarif` | SARIF 2.1.0, the standard for GitHub Code Scanning and other CI tools |
163
+ | `--fail-on ERROR\|WARNING\|INFO` | Exit code 1 as soon as a finding is at least that severe. Without this flag the exit code is always 0. |
164
+
165
+ > **Note:** JSON and SARIF include the flagged source line or description (`evidence`),
166
+ > which comes straight from the scanned code. Do not pass these reports to an AI agent.
167
+
168
+ Example for GitHub Actions: fail the build on errors and upload the results to GitHub
169
+ Code Scanning.
170
+
171
+ ```yaml
172
+ name: MCP security scan
173
+ on: [push, pull_request]
174
+
175
+ jobs:
176
+ scan:
177
+ runs-on: ubuntu-latest
178
+ permissions:
179
+ contents: read
180
+ security-events: write
181
+ steps:
182
+ - uses: actions/checkout@v4
183
+ - uses: actions/setup-python@v5
184
+ with:
185
+ python-version: "3.12"
186
+ - run: pip install git+https://github.com/0xtahaa/MCPThreat-Scan.git
187
+ - run: mcpthreat-scan scan . --format sarif --fail-on ERROR > results.sarif
188
+ - if: always()
189
+ uses: github/codeql-action/upload-sarif@v3
190
+ with:
191
+ sarif_file: results.sarif
192
+ ```
193
+
194
+ ### Interactive interface (TUI)
195
+
196
+ ```bash
197
+ mcpthreat-scan tui
198
+ ```
199
+
200
+ ![Main menu](docs/tui/01_menu_empty.svg)
201
+
202
+ From the main menu you can:
203
+
204
+ - **Start New Scan:** pick a file or folder, confirm, follow the scan and read the summary
205
+ - **View Findings:** filter by severity and open a detail view with description and
206
+ recommendation for each finding
207
+ - **Compare Versions:** compare two files or two folders and see changed tool definitions
208
+ plus new and resolved findings
209
+ - **Trusted Servers & Exclusions:** manage trusted servers and ignore rules
210
+ - **Export:** save the report as JSON or SARIF with `E`
211
+
212
+ ![Finding details](docs/tui/07_findings_detail.svg)
213
+
214
+ Shortcuts are shown on every screen. On the main menu: `S` scan, `D` compare, `?` help,
215
+ `Q` quit. A running scan cannot be cancelled safely, because Semgrep runs as one external
216
+ process.
217
+
218
+ ## Configuration
219
+
220
+ ### Ignoring findings
221
+
222
+ If you have reviewed a finding and accept it, ignore it. In the TUI, open the finding and press
223
+ `i`. The rule is saved in a file called `.mcpscannerignore` in the folder you run the scan from.
224
+
225
+ On the command line or in CI you can edit that file yourself, one rule per line as
226
+ `file:Category`:
227
+
228
+ ```text
229
+ # reviewed and accepted
230
+ src/server.py:Missing Audit Logging
231
+ ```
232
+
233
+ Ignored findings are counted in the summary, so nothing disappears silently.
234
+
235
+ ### Network access and your data
236
+
237
+ The scan reads your code locally. Two features talk to external services:
238
+
239
+ | Feature | What is sent |
240
+ |---|---|
241
+ | Supply-chain check | Dependency names and versions are looked up in the OSV vulnerability database through `pip-audit` |
242
+ | `--ai-review` | The text of each tool-poisoning candidate (the flagged tool description or handler output, not whole files) goes to the OpenAI API, default model `gpt-4o-mini` |
243
+
244
+ For the AI review, the candidate text is wrapped in markers and the model is instructed to treat
245
+ it as data only. Your `OPENAI_API_KEY` is read from the environment or a local `.env` file.
246
+ Checking `package-lock.json` for npm projects needs the separate
247
+ [osv-scanner](https://google.github.io/osv-scanner/) program on your `PATH`.
248
+
249
+ ## What it checks
250
+
251
+ MCPThreat-Scan checks for the most common known vulnerabilities in MCP servers, based on OWASP.
252
+
253
+ | Category | What is checked |
254
+ |---|---|
255
+ | Hardcoded Secret | API keys or tokens written directly in the source code |
256
+ | Command Injection | Tool input that reaches `eval`, `exec`, `os.system` or `subprocess` without checks |
257
+ | Header Leak | Request headers ending up in error messages |
258
+ | Unscoped Environment Access | Environment variables read on every tool call instead of once at startup |
259
+ | Tool Poisoning | Hidden instructions for AI agents in tool descriptions or tool output. Rug pulls are found with `diff`. |
260
+ | Supply Chain | Dependencies with known vulnerabilities (`requirements.txt`, and `package-lock.json` with osv-scanner) |
261
+ | Missing Audit Logging | Security-relevant actions without any logging |
262
+ | Capability Mismatch | A tool that makes network or email calls without saying so in its name or description. This is a keyword heuristic and does not detect deliberately deceptive descriptions. |
263
+ | Typosquatting / Shadow Server | A server name that closely resembles a known server. A candidate, not proof. |
264
+
265
+ Command Injection, Hardcoded Secret, Header Leak, Tool Poisoning and Unscoped Environment Access
266
+ cover Python and TypeScript/JavaScript. Capability Mismatch and Missing Audit Logging currently
267
+ cover Python only.
268
+
269
+ Not covered: precise scope measurement (needs runtime tracing), a general prompt-injection content
270
+ filter, server operations monitoring and shadow-server discovery.
271
+
272
+ ## Benchmark
273
+
274
+ The rules are tested against example servers with known vulnerabilities and known-clean
275
+ examples in [`benchmark/`](benchmark/). Run it yourself from the repository root:
276
+
277
+ ```bash
278
+ python -m benchmark.evaluate
279
+ ```
280
+
281
+ Result without `--ai-review` (rules and supply-chain check only):
282
+
283
+ | Category | TP | FP | FN | Precision | Recall |
284
+ |---|---|---|---|---|---|
285
+ | Capability Mismatch | 2 | 0 | 0 | 100 % | 100 % |
286
+ | Command Injection | 2 | 0 | 0 | 100 % | 100 % |
287
+ | Hardcoded Secret | 2 | 0 | 0 | 100 % | 100 % |
288
+ | Header Leak | 2 | 0 | 0 | 100 % | 100 % |
289
+ | Missing Audit Logging | 6 | 0 | 0 | 100 % | 100 % |
290
+ | Supply Chain | 2 | 0 | 0 | 100 % | 100 % |
291
+ | Tool Poisoning | 6 | 1 | 2 | 86 % | 75 % |
292
+ | Typosquatting / Shadow Server | 2 | 0 | 0 | 100 % | 100 % |
293
+ | Unscoped Environment Access | 5 | 0 | 0 | 100 % | 100 % |
294
+ | **Total** | **29** | **1** | **2** | **97 %** | **94 %** |
295
+
296
+ **How to read this:** The examples were written together with the rules, so the benchmark
297
+ shows that the rules do what they are meant to do. It is not an independent measurement of
298
+ accuracy on real-world servers. A sample of 40 findings from public MCP servers is prepared for
299
+ manual rating ([`benchmark/precision_sample.csv`](benchmark/precision_sample.csv)). The
300
+ real-world precision will be published once it is rated.
301
+
302
+ Tool Poisoning is weaker on purpose: the rules only deliver candidates, and `--ai-review` is
303
+ what confirms them. The AI review is not measured here. The two misses are rug-pull cases from
304
+ `benchmark/rugpull/`, see [Limitations](#limitations).
305
+
306
+ ## Limitations
307
+
308
+ - **Findings are candidates, not proof.** Some checks (Tool Poisoning, Capability Mismatch,
309
+ Typosquatting) are heuristics. They can raise false alarms, and a carefully disguised attack
310
+ can slip through. `--ai-review` helps to confirm Tool Poisoning candidates, but it is not
311
+ measured in the benchmark.
312
+ - **Only static analysis.** The scanner never runs the code, so it cannot see what a server does
313
+ at runtime.
314
+ - **Languages:** Python and TypeScript/JavaScript. Capability Mismatch and Missing Audit Logging
315
+ cover Python only.
316
+ - **Rug-pull detection compares two versions that you provide.** It does not watch a server over
317
+ time. In the benchmark it misses two cases (`benchmark/rugpull/`), and these cases are not part
318
+ of the automatic benchmark run.
319
+ - **No real-world accuracy figures yet.** See [Benchmark](#benchmark).
320
+
321
+ ## Contributing
322
+
323
+ Issues and pull requests are welcome. Before opening a pull request, run the tests and the
324
+ benchmark:
325
+
326
+ ```bash
327
+ pip install -e ".[dev]"
328
+ pytest
329
+ python -m benchmark.evaluate
330
+ ```
331
+
332
+ ## Development
333
+
334
+ ### Project structure
335
+
336
+ ```
337
+ src/mcpthreat_scan/
338
+ cli/ Command-line interface (argparse: scan, diff, tui) — parsing only, delegates to core
339
+ tui/ Interactive terminal interface (Textual)
340
+ core/ Orchestration (run_scan, run_diff), categories/severities, shared exceptions
341
+ analyzers/ Semgrep (layer 1), AI review (layer 2, OpenAI), supply chain (pip-audit/OSV),
342
+ typosquat, capability post-filter — one task per analyzer, no analyzer chains
343
+ diff/ AST extraction of tool functions (never executed) and rug-pull comparison
344
+ policy/ .mcpscannerignore and reputation/whitelist
345
+ reporting/ Renderers for text, JSON and SARIF
346
+ resources/ Semgrep rules (rules/, one file per OWASP MCP category), known_mcp_servers.json
347
+ benchmark/ Test cases with known results (vulnerable/, clean/, rugpull/) + expected_results.json
348
+ + evaluate.py (precision/recall; uses the core API, not part of the installable package)
349
+ tests/ Unit tests (pytest)
350
+ ```
351
+
352
+ ### Known issues
353
+
354
+ - **`policy/reputation.py` is not used by the scan.** The whitelist/fingerprint mechanism (meant to
355
+ skip costly re-review for established, unchanged servers) is not wired into the scan pipeline;
356
+ only the TUI management (`list_reviewed`, `revoke_review`) and the tests call it.
357
+ - Two tests (`test_ai_review.py`, real OpenAI call) are skipped without `OPENAI_API_KEY`. Tests
358
+ with an OSV query via `pip-audit` (`test_dependency_check.py`) need network access and may fail
359
+ without it, which is an external dependency and not a code error.
360
+
361
+ ## License
362
+
363
+ Apache License 2.0, see [LICENSE](LICENSE).