frame-mcp 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.
- frame_mcp-0.1.0/LICENSE +202 -0
- frame_mcp-0.1.0/PKG-INFO +165 -0
- frame_mcp-0.1.0/README.md +145 -0
- frame_mcp-0.1.0/pyproject.toml +44 -0
- frame_mcp-0.1.0/server.json +43 -0
- frame_mcp-0.1.0/src/frame_mcp/__init__.py +3 -0
- frame_mcp-0.1.0/src/frame_mcp/server.py +455 -0
- frame_mcp-0.1.0/tests/test_server.py +192 -0
frame_mcp-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
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.
|
|
202
|
+
|
frame_mcp-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: frame-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Model Context Protocol server for the Frame security scanner.
|
|
5
|
+
Project-URL: Homepage, https://github.com/lambdasec/frame
|
|
6
|
+
Project-URL: Repository, https://github.com/lambdasec/frame-mcp
|
|
7
|
+
Author: lambdasec
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: frame,mcp,sast,security,taint-analysis
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Security
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Requires-Dist: frame-security[scan]>=1.0.0
|
|
18
|
+
Requires-Dist: mcp>=1.2.0
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# frame-mcp
|
|
22
|
+
|
|
23
|
+
mcp-name: io.github.lambdasec/frame-mcp
|
|
24
|
+
|
|
25
|
+
An MCP server that exposes the [Frame](https://github.com/lambdasec/frame) security scanner to any MCP client, so a coding agent can scan code, verify fixes, and reason about vulnerabilities over stdio.
|
|
26
|
+
|
|
27
|
+
Frame combines taint analysis with separation logic verification to find data-flow vulnerabilities (SQL injection, command injection, path traversal, and more), and checks each reported path with a solver. This package wraps the `frame` command line program as MCP tools. It launches `frame` as a subprocess with an explicit argument list, never a shell, and prefers the `frame` executable installed next to the running Python interpreter.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
Run directly with uvx (no separate install step):
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
uvx frame-mcp
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Claude Code
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
claude mcp add frame -- uvx frame-mcp
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Codex
|
|
44
|
+
|
|
45
|
+
Add this stanza to `~/.codex/config.toml`:
|
|
46
|
+
|
|
47
|
+
```toml
|
|
48
|
+
[mcp_servers.frame]
|
|
49
|
+
command = "uvx"
|
|
50
|
+
args = ["frame-mcp"]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Cursor
|
|
54
|
+
|
|
55
|
+
Create `.cursor/mcp.json`:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"mcpServers": {
|
|
60
|
+
"frame": {
|
|
61
|
+
"command": "uvx",
|
|
62
|
+
"args": ["frame-mcp"]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### VS Code
|
|
69
|
+
|
|
70
|
+
Create `.vscode/mcp.json`:
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"servers": {
|
|
75
|
+
"frame": {
|
|
76
|
+
"type": "stdio",
|
|
77
|
+
"command": "uvx",
|
|
78
|
+
"args": ["frame-mcp"]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Windsurf
|
|
85
|
+
|
|
86
|
+
Add to `~/.codeium/windsurf/mcp_config.json` under the `mcpServers` key:
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"mcpServers": {
|
|
91
|
+
"frame": {
|
|
92
|
+
"command": "uvx",
|
|
93
|
+
"args": ["frame-mcp"]
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Gemini CLI
|
|
100
|
+
|
|
101
|
+
Add to `~/.gemini/settings.json` under the `mcpServers` key:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"mcpServers": {
|
|
106
|
+
"frame": {
|
|
107
|
+
"command": "uvx",
|
|
108
|
+
"args": ["frame-mcp"]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Zed
|
|
115
|
+
|
|
116
|
+
Add to Zed `settings.json` under `context_servers`:
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"context_servers": {
|
|
121
|
+
"frame": {
|
|
122
|
+
"command": {
|
|
123
|
+
"path": "uvx",
|
|
124
|
+
"args": ["frame-mcp"]
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Tools
|
|
132
|
+
|
|
133
|
+
| Tool | Purpose | Read only |
|
|
134
|
+
| --- | --- | --- |
|
|
135
|
+
| `scan` | Scan a file or directory for vulnerabilities and return findings as JSON. | yes |
|
|
136
|
+
| `write_baseline` | Scan a path and record the findings as a baseline file. | no |
|
|
137
|
+
| `verify` | Re-scan the files behind earlier findings and report whether each is fixed. | yes |
|
|
138
|
+
| `fix` | Generate and verify fixes for findings. Returns a diff by default. | no |
|
|
139
|
+
| `exploit` | Drive an agent to exploit a live, authorized target. | no |
|
|
140
|
+
| `packs_list` | List the framework packs a scan would load. | yes |
|
|
141
|
+
| `packs_check` | Validate framework pack files. | yes |
|
|
142
|
+
| `solve` | Check a separation logic entailment `P \|- Q`. | yes |
|
|
143
|
+
|
|
144
|
+
A `security-review` prompt chains `scan` (with the AI layer), `verify`, and an offer to `fix`.
|
|
145
|
+
|
|
146
|
+
## AI features and environment variables
|
|
147
|
+
|
|
148
|
+
The `scan` tool with `ai=true`, along with `fix` and `exploit`, call an LLM through an OpenAI-compatible endpoint. Configure it with these environment variables in the MCP client that launches the server:
|
|
149
|
+
|
|
150
|
+
| Variable | Purpose |
|
|
151
|
+
| --- | --- |
|
|
152
|
+
| `FRAME_LLM_BASE_URL` | Base URL of the LLM endpoint, for example a local server or a hosted API. |
|
|
153
|
+
| `FRAME_LLM_API_KEY` | API key for the endpoint, when it requires one. |
|
|
154
|
+
| `FRAME_LLM_MODEL` | Model name to request. |
|
|
155
|
+
| `FRAME_LLM_REPO_ROOT` | Repository root for relative path resolution. |
|
|
156
|
+
|
|
157
|
+
These are inherited from the server process environment and forwarded to each `frame` subprocess. The plain `scan` (taint analysis plus verification) needs none of them.
|
|
158
|
+
|
|
159
|
+
## Exploit authorization
|
|
160
|
+
|
|
161
|
+
The `exploit` tool drives an autonomous agent that sends live traffic to a target. Run it only against systems you own or are explicitly authorized to test. Unauthorized testing of systems you do not control may be illegal.
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# frame-mcp
|
|
2
|
+
|
|
3
|
+
mcp-name: io.github.lambdasec/frame-mcp
|
|
4
|
+
|
|
5
|
+
An MCP server that exposes the [Frame](https://github.com/lambdasec/frame) security scanner to any MCP client, so a coding agent can scan code, verify fixes, and reason about vulnerabilities over stdio.
|
|
6
|
+
|
|
7
|
+
Frame combines taint analysis with separation logic verification to find data-flow vulnerabilities (SQL injection, command injection, path traversal, and more), and checks each reported path with a solver. This package wraps the `frame` command line program as MCP tools. It launches `frame` as a subprocess with an explicit argument list, never a shell, and prefers the `frame` executable installed next to the running Python interpreter.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
Run directly with uvx (no separate install step):
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
uvx frame-mcp
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Claude Code
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
claude mcp add frame -- uvx frame-mcp
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Codex
|
|
24
|
+
|
|
25
|
+
Add this stanza to `~/.codex/config.toml`:
|
|
26
|
+
|
|
27
|
+
```toml
|
|
28
|
+
[mcp_servers.frame]
|
|
29
|
+
command = "uvx"
|
|
30
|
+
args = ["frame-mcp"]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Cursor
|
|
34
|
+
|
|
35
|
+
Create `.cursor/mcp.json`:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"mcpServers": {
|
|
40
|
+
"frame": {
|
|
41
|
+
"command": "uvx",
|
|
42
|
+
"args": ["frame-mcp"]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### VS Code
|
|
49
|
+
|
|
50
|
+
Create `.vscode/mcp.json`:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"servers": {
|
|
55
|
+
"frame": {
|
|
56
|
+
"type": "stdio",
|
|
57
|
+
"command": "uvx",
|
|
58
|
+
"args": ["frame-mcp"]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Windsurf
|
|
65
|
+
|
|
66
|
+
Add to `~/.codeium/windsurf/mcp_config.json` under the `mcpServers` key:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"mcpServers": {
|
|
71
|
+
"frame": {
|
|
72
|
+
"command": "uvx",
|
|
73
|
+
"args": ["frame-mcp"]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Gemini CLI
|
|
80
|
+
|
|
81
|
+
Add to `~/.gemini/settings.json` under the `mcpServers` key:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"mcpServers": {
|
|
86
|
+
"frame": {
|
|
87
|
+
"command": "uvx",
|
|
88
|
+
"args": ["frame-mcp"]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Zed
|
|
95
|
+
|
|
96
|
+
Add to Zed `settings.json` under `context_servers`:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"context_servers": {
|
|
101
|
+
"frame": {
|
|
102
|
+
"command": {
|
|
103
|
+
"path": "uvx",
|
|
104
|
+
"args": ["frame-mcp"]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Tools
|
|
112
|
+
|
|
113
|
+
| Tool | Purpose | Read only |
|
|
114
|
+
| --- | --- | --- |
|
|
115
|
+
| `scan` | Scan a file or directory for vulnerabilities and return findings as JSON. | yes |
|
|
116
|
+
| `write_baseline` | Scan a path and record the findings as a baseline file. | no |
|
|
117
|
+
| `verify` | Re-scan the files behind earlier findings and report whether each is fixed. | yes |
|
|
118
|
+
| `fix` | Generate and verify fixes for findings. Returns a diff by default. | no |
|
|
119
|
+
| `exploit` | Drive an agent to exploit a live, authorized target. | no |
|
|
120
|
+
| `packs_list` | List the framework packs a scan would load. | yes |
|
|
121
|
+
| `packs_check` | Validate framework pack files. | yes |
|
|
122
|
+
| `solve` | Check a separation logic entailment `P \|- Q`. | yes |
|
|
123
|
+
|
|
124
|
+
A `security-review` prompt chains `scan` (with the AI layer), `verify`, and an offer to `fix`.
|
|
125
|
+
|
|
126
|
+
## AI features and environment variables
|
|
127
|
+
|
|
128
|
+
The `scan` tool with `ai=true`, along with `fix` and `exploit`, call an LLM through an OpenAI-compatible endpoint. Configure it with these environment variables in the MCP client that launches the server:
|
|
129
|
+
|
|
130
|
+
| Variable | Purpose |
|
|
131
|
+
| --- | --- |
|
|
132
|
+
| `FRAME_LLM_BASE_URL` | Base URL of the LLM endpoint, for example a local server or a hosted API. |
|
|
133
|
+
| `FRAME_LLM_API_KEY` | API key for the endpoint, when it requires one. |
|
|
134
|
+
| `FRAME_LLM_MODEL` | Model name to request. |
|
|
135
|
+
| `FRAME_LLM_REPO_ROOT` | Repository root for relative path resolution. |
|
|
136
|
+
|
|
137
|
+
These are inherited from the server process environment and forwarded to each `frame` subprocess. The plain `scan` (taint analysis plus verification) needs none of them.
|
|
138
|
+
|
|
139
|
+
## Exploit authorization
|
|
140
|
+
|
|
141
|
+
The `exploit` tool drives an autonomous agent that sends live traffic to a target. Run it only against systems you own or are explicitly authorized to test. Unauthorized testing of systems you do not control may be illegal.
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "frame-mcp"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Model Context Protocol server for the Frame security scanner."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "lambdasec" }]
|
|
14
|
+
keywords = ["mcp", "security", "sast", "frame", "taint-analysis"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"License :: OSI Approved :: Apache Software License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Topic :: Security",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"frame-security[scan]>=1.0.0",
|
|
24
|
+
"mcp>=1.2.0",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://github.com/lambdasec/frame"
|
|
29
|
+
Repository = "https://github.com/lambdasec/frame-mcp"
|
|
30
|
+
|
|
31
|
+
[project.scripts]
|
|
32
|
+
frame-mcp = "frame_mcp.server:main"
|
|
33
|
+
|
|
34
|
+
[tool.hatch.build.targets.wheel]
|
|
35
|
+
packages = ["src/frame_mcp"]
|
|
36
|
+
|
|
37
|
+
[tool.hatch.build.targets.sdist]
|
|
38
|
+
include = [
|
|
39
|
+
"src/frame_mcp",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE",
|
|
42
|
+
"server.json",
|
|
43
|
+
"tests",
|
|
44
|
+
]
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.lambdasec/frame-mcp",
|
|
4
|
+
"description": "MCP server for the Frame security scanner: scan, verify, fix, exploit, packs and separation logic.",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"url": "https://github.com/lambdasec/frame-mcp",
|
|
8
|
+
"source": "github"
|
|
9
|
+
},
|
|
10
|
+
"packages": [
|
|
11
|
+
{
|
|
12
|
+
"registryType": "pypi",
|
|
13
|
+
"identifier": "frame-mcp",
|
|
14
|
+
"version": "0.1.0",
|
|
15
|
+
"transport": {
|
|
16
|
+
"type": "stdio"
|
|
17
|
+
},
|
|
18
|
+
"environmentVariables": [
|
|
19
|
+
{
|
|
20
|
+
"name": "FRAME_LLM_BASE_URL",
|
|
21
|
+
"description": "Base URL of an OpenAI-compatible LLM endpoint for the AI detection, triage, fix and exploit features.",
|
|
22
|
+
"isRequired": false
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "FRAME_LLM_API_KEY",
|
|
26
|
+
"description": "API key for the LLM endpoint, when the endpoint requires one.",
|
|
27
|
+
"isRequired": false,
|
|
28
|
+
"isSecret": true
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "FRAME_LLM_MODEL",
|
|
32
|
+
"description": "Model name to request from the LLM endpoint.",
|
|
33
|
+
"isRequired": false
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "FRAME_LLM_REPO_ROOT",
|
|
37
|
+
"description": "Repository root the LLM layer resolves relative paths against.",
|
|
38
|
+
"isRequired": false
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
"""MCP stdio server that exposes the Frame security scanner CLI as tools.
|
|
2
|
+
|
|
3
|
+
The server shells out to the ``frame`` command line program using an explicit
|
|
4
|
+
argument list (never ``shell=True``). It prefers the ``frame`` executable that
|
|
5
|
+
sits next to the running Python interpreter, falling back to ``PATH``.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import json
|
|
11
|
+
import os
|
|
12
|
+
import shutil
|
|
13
|
+
import subprocess
|
|
14
|
+
import sys
|
|
15
|
+
import tempfile
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
from typing import Any, Optional, Union
|
|
18
|
+
|
|
19
|
+
try:
|
|
20
|
+
# mcp 1.x
|
|
21
|
+
from mcp.server.fastmcp import FastMCP as _Server
|
|
22
|
+
except ModuleNotFoundError:
|
|
23
|
+
# mcp 2.x renamed FastMCP to MCPServer
|
|
24
|
+
from mcp.server.mcpserver import MCPServer as _Server
|
|
25
|
+
|
|
26
|
+
from mcp.types import ToolAnnotations
|
|
27
|
+
|
|
28
|
+
FindingsInput = Union[str, dict, list]
|
|
29
|
+
|
|
30
|
+
# Environment variables the Frame LLM layer reads. They are inherited from the
|
|
31
|
+
# server process environment and forwarded to every subprocess.
|
|
32
|
+
_FRAME_LLM_ENV = (
|
|
33
|
+
"FRAME_LLM_BASE_URL",
|
|
34
|
+
"FRAME_LLM_API_KEY",
|
|
35
|
+
"FRAME_LLM_MODEL",
|
|
36
|
+
"FRAME_LLM_REPO_ROOT",
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
mcp = _Server("frame")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# --------------------------------------------------------------------------
|
|
43
|
+
# process helpers
|
|
44
|
+
# --------------------------------------------------------------------------
|
|
45
|
+
def _frame_executable() -> str:
|
|
46
|
+
"""Resolve the frame binary: next to sys.executable first, then PATH."""
|
|
47
|
+
candidate = Path(sys.executable).resolve().parent / "frame"
|
|
48
|
+
if candidate.is_file():
|
|
49
|
+
return str(candidate)
|
|
50
|
+
found = shutil.which("frame")
|
|
51
|
+
if found:
|
|
52
|
+
return found
|
|
53
|
+
# Let subprocess raise a clear FileNotFoundError if it is genuinely absent.
|
|
54
|
+
return "frame"
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _subprocess_env() -> dict:
|
|
58
|
+
"""Copy the current environment (carries the FRAME_LLM_* passthrough)."""
|
|
59
|
+
env = os.environ.copy()
|
|
60
|
+
# Explicit: ensure the documented variables survive even if a caller
|
|
61
|
+
# restricted the inherited environment. Absent ones are simply skipped.
|
|
62
|
+
for name in _FRAME_LLM_ENV:
|
|
63
|
+
value = os.environ.get(name)
|
|
64
|
+
if value is not None:
|
|
65
|
+
env[name] = value
|
|
66
|
+
return env
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _parse_output(proc: subprocess.CompletedProcess) -> Any:
|
|
70
|
+
"""Return parsed JSON stdout, else a raw stdout/stderr/exit_code fallback."""
|
|
71
|
+
text = proc.stdout or ""
|
|
72
|
+
try:
|
|
73
|
+
return json.loads(text)
|
|
74
|
+
except (ValueError, TypeError):
|
|
75
|
+
return {
|
|
76
|
+
"stdout": text,
|
|
77
|
+
"stderr": proc.stderr or "",
|
|
78
|
+
"exit_code": proc.returncode,
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _run_frame(
|
|
83
|
+
args: list[str],
|
|
84
|
+
*,
|
|
85
|
+
timeout: float,
|
|
86
|
+
ok_codes: tuple[int, ...] = (0, 1),
|
|
87
|
+
) -> Any:
|
|
88
|
+
"""Run ``frame <args>`` and return parsed JSON, raising on an error exit.
|
|
89
|
+
|
|
90
|
+
Exit codes in ``ok_codes`` (default 0 and 1) are treated as success. Any
|
|
91
|
+
other code (for example 2, the "cannot verify" status) is surfaced as an
|
|
92
|
+
error that carries the captured stderr.
|
|
93
|
+
"""
|
|
94
|
+
cmd = [_frame_executable(), *args]
|
|
95
|
+
try:
|
|
96
|
+
proc = subprocess.run(
|
|
97
|
+
cmd,
|
|
98
|
+
capture_output=True,
|
|
99
|
+
text=True,
|
|
100
|
+
env=_subprocess_env(),
|
|
101
|
+
timeout=timeout,
|
|
102
|
+
check=False,
|
|
103
|
+
)
|
|
104
|
+
except FileNotFoundError as exc:
|
|
105
|
+
raise RuntimeError(
|
|
106
|
+
"The 'frame' executable was not found. Install frame-security "
|
|
107
|
+
"with: pip install 'frame-security[scan]'."
|
|
108
|
+
) from exc
|
|
109
|
+
except subprocess.TimeoutExpired as exc:
|
|
110
|
+
raise RuntimeError(
|
|
111
|
+
f"frame timed out after {timeout:g}s: {' '.join(args)}"
|
|
112
|
+
) from exc
|
|
113
|
+
|
|
114
|
+
if proc.returncode not in ok_codes:
|
|
115
|
+
stderr = (proc.stderr or "").strip()
|
|
116
|
+
stdout = (proc.stdout or "").strip()
|
|
117
|
+
detail = stderr or stdout or "no output"
|
|
118
|
+
raise RuntimeError(
|
|
119
|
+
f"frame exited with status {proc.returncode}: {detail}"
|
|
120
|
+
)
|
|
121
|
+
return _parse_output(proc)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _write_findings_tempfile(findings_json: FindingsInput) -> str:
|
|
125
|
+
"""Accept a JSON string or an object and write it to a temp file.
|
|
126
|
+
|
|
127
|
+
Returns the path to a temporary file the caller is responsible for
|
|
128
|
+
deleting.
|
|
129
|
+
"""
|
|
130
|
+
if isinstance(findings_json, (dict, list)):
|
|
131
|
+
payload = json.dumps(findings_json)
|
|
132
|
+
else:
|
|
133
|
+
payload = str(findings_json)
|
|
134
|
+
handle = tempfile.NamedTemporaryFile(
|
|
135
|
+
mode="w", suffix=".json", delete=False, encoding="utf-8"
|
|
136
|
+
)
|
|
137
|
+
try:
|
|
138
|
+
handle.write(payload)
|
|
139
|
+
finally:
|
|
140
|
+
handle.close()
|
|
141
|
+
return handle.name
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
# --------------------------------------------------------------------------
|
|
145
|
+
# argument builders (pure functions, unit tested without any process launch)
|
|
146
|
+
# --------------------------------------------------------------------------
|
|
147
|
+
def _build_scan_args(
|
|
148
|
+
path: str,
|
|
149
|
+
language: Optional[str] = None,
|
|
150
|
+
ai: bool = False,
|
|
151
|
+
changed_ref: Optional[str] = None,
|
|
152
|
+
files: Optional[list[str]] = None,
|
|
153
|
+
baseline: Optional[str] = None,
|
|
154
|
+
min_severity: Optional[str] = None,
|
|
155
|
+
fail_on: str = "none",
|
|
156
|
+
root: Optional[str] = None,
|
|
157
|
+
no_cross_file: bool = False,
|
|
158
|
+
packs: Optional[list[str]] = None,
|
|
159
|
+
) -> list[str]:
|
|
160
|
+
args = ["scan", path, "-f", "json", "--fail-on", fail_on]
|
|
161
|
+
if language:
|
|
162
|
+
args += ["-l", language]
|
|
163
|
+
if ai:
|
|
164
|
+
args += ["--ai"]
|
|
165
|
+
if changed_ref is not None:
|
|
166
|
+
args += ["--changed", changed_ref]
|
|
167
|
+
if files:
|
|
168
|
+
args += ["--files", *files]
|
|
169
|
+
if baseline:
|
|
170
|
+
args += ["--baseline", baseline]
|
|
171
|
+
if min_severity:
|
|
172
|
+
args += ["--min-severity", min_severity]
|
|
173
|
+
if root:
|
|
174
|
+
args += ["--root", root]
|
|
175
|
+
if no_cross_file:
|
|
176
|
+
args += ["--no-cross-file"]
|
|
177
|
+
for pack in packs or []:
|
|
178
|
+
args += ["--pack", pack]
|
|
179
|
+
return args
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def _build_write_baseline_args(path: str, baseline_file: str) -> list[str]:
|
|
183
|
+
return ["scan", path, "--write-baseline", baseline_file, "--fail-on", "none"]
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def _build_verify_args(
|
|
187
|
+
findings_source: str, ids: Optional[list[str]] = None
|
|
188
|
+
) -> list[str]:
|
|
189
|
+
args = ["verify", findings_source, "-f", "json"]
|
|
190
|
+
for fp in ids or []:
|
|
191
|
+
args += ["--id", fp]
|
|
192
|
+
return args
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def _build_fix_args(
|
|
196
|
+
path: str, guidance_file: str, in_place: bool = False
|
|
197
|
+
) -> list[str]:
|
|
198
|
+
args = ["fix", path, "--guidance", guidance_file, "--format", "json"]
|
|
199
|
+
if in_place:
|
|
200
|
+
args += ["--in-place"]
|
|
201
|
+
return args
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def _build_exploit_args(
|
|
205
|
+
target: str,
|
|
206
|
+
guidance_file: Optional[str] = None,
|
|
207
|
+
goal: Optional[str] = None,
|
|
208
|
+
success_check: Optional[str] = None,
|
|
209
|
+
max_steps: Optional[int] = None,
|
|
210
|
+
) -> list[str]:
|
|
211
|
+
args = ["exploit", "--target", target, "--format", "json"]
|
|
212
|
+
if guidance_file:
|
|
213
|
+
args += ["--guidance", guidance_file]
|
|
214
|
+
if goal:
|
|
215
|
+
args += ["--goal", goal]
|
|
216
|
+
if success_check:
|
|
217
|
+
args += ["--success-check", success_check]
|
|
218
|
+
if max_steps is not None:
|
|
219
|
+
args += ["--max-steps", str(max_steps)]
|
|
220
|
+
return args
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def _build_solve_args(entailment: str, model: bool = False) -> list[str]:
|
|
224
|
+
args = ["solve", entailment, "--format", "json"]
|
|
225
|
+
if model:
|
|
226
|
+
args += ["--model"]
|
|
227
|
+
return args
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def _build_packs_list_args(path: Optional[str] = None) -> list[str]:
|
|
231
|
+
args = ["packs", "list"]
|
|
232
|
+
if path:
|
|
233
|
+
args += ["--project", path]
|
|
234
|
+
return args
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def _build_packs_check_args(files: list[str]) -> list[str]:
|
|
238
|
+
return ["packs", "check", *files]
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
# --------------------------------------------------------------------------
|
|
242
|
+
# tools
|
|
243
|
+
# --------------------------------------------------------------------------
|
|
244
|
+
@mcp.tool(
|
|
245
|
+
annotations=ToolAnnotations(title="Scan source for vulnerabilities", readOnlyHint=True),
|
|
246
|
+
)
|
|
247
|
+
def scan(
|
|
248
|
+
path: str,
|
|
249
|
+
language: Optional[str] = None,
|
|
250
|
+
ai: bool = False,
|
|
251
|
+
changed_ref: Optional[str] = None,
|
|
252
|
+
files: Optional[list[str]] = None,
|
|
253
|
+
baseline: Optional[str] = None,
|
|
254
|
+
min_severity: Optional[str] = None,
|
|
255
|
+
fail_on: str = "none",
|
|
256
|
+
root: Optional[str] = None,
|
|
257
|
+
no_cross_file: bool = False,
|
|
258
|
+
packs: Optional[list[str]] = None,
|
|
259
|
+
) -> Any:
|
|
260
|
+
"""Scan a file or directory for security vulnerabilities with Frame.
|
|
261
|
+
|
|
262
|
+
Runs taint analysis plus separation logic verification and returns the
|
|
263
|
+
findings as JSON. Set ``ai=True`` to add the LLM detection and triage
|
|
264
|
+
layer (needs the FRAME_LLM_* environment variables). ``changed_ref`` scans
|
|
265
|
+
only files that differ from a git ref; ``files`` restricts the scan to a
|
|
266
|
+
list of files; ``baseline`` reports only findings absent from a baseline
|
|
267
|
+
file; ``packs`` loads extra framework packs. This tool does not modify any
|
|
268
|
+
files.
|
|
269
|
+
"""
|
|
270
|
+
args = _build_scan_args(
|
|
271
|
+
path,
|
|
272
|
+
language=language,
|
|
273
|
+
ai=ai,
|
|
274
|
+
changed_ref=changed_ref,
|
|
275
|
+
files=files,
|
|
276
|
+
baseline=baseline,
|
|
277
|
+
min_severity=min_severity,
|
|
278
|
+
fail_on=fail_on,
|
|
279
|
+
root=root,
|
|
280
|
+
no_cross_file=no_cross_file,
|
|
281
|
+
packs=packs,
|
|
282
|
+
)
|
|
283
|
+
timeout = 1800.0 if ai else 300.0
|
|
284
|
+
return _run_frame(args, timeout=timeout, ok_codes=(0, 1))
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
@mcp.tool(
|
|
288
|
+
annotations=ToolAnnotations(
|
|
289
|
+
title="Write a scan baseline file",
|
|
290
|
+
readOnlyHint=False,
|
|
291
|
+
destructiveHint=False,
|
|
292
|
+
),
|
|
293
|
+
)
|
|
294
|
+
def write_baseline(path: str, baseline_file: str) -> Any:
|
|
295
|
+
"""Scan ``path`` and record the findings as a baseline file.
|
|
296
|
+
|
|
297
|
+
Writes ``baseline_file`` to disk (creating or overwriting it) and uses
|
|
298
|
+
``--fail-on none`` so the current state is accepted. Later scans can pass
|
|
299
|
+
this file as ``baseline`` to report only new findings.
|
|
300
|
+
"""
|
|
301
|
+
args = _build_write_baseline_args(path, baseline_file)
|
|
302
|
+
return _run_frame(args, timeout=300.0, ok_codes=(0, 1))
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
@mcp.tool(
|
|
306
|
+
annotations=ToolAnnotations(title="Verify earlier findings are fixed", readOnlyHint=True),
|
|
307
|
+
)
|
|
308
|
+
def verify(findings_json: FindingsInput, ids: Optional[list[str]] = None) -> Any:
|
|
309
|
+
"""Re-scan the files behind earlier findings and report their status.
|
|
310
|
+
|
|
311
|
+
``findings_json`` is the JSON produced by ``scan`` (a JSON string or the
|
|
312
|
+
parsed object). Each finding comes back as fixed, file_removed, present,
|
|
313
|
+
suppressed, uncertain or unverifiable. Pass ``ids`` (finding fingerprints)
|
|
314
|
+
to check only specific findings. This tool does not modify any files.
|
|
315
|
+
"""
|
|
316
|
+
findings_file = _write_findings_tempfile(findings_json)
|
|
317
|
+
try:
|
|
318
|
+
args = _build_verify_args(findings_file, ids=ids)
|
|
319
|
+
return _run_frame(args, timeout=300.0, ok_codes=(0, 1))
|
|
320
|
+
finally:
|
|
321
|
+
_safe_unlink(findings_file)
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
@mcp.tool(
|
|
325
|
+
annotations=ToolAnnotations(
|
|
326
|
+
title="Generate verified security fixes",
|
|
327
|
+
readOnlyHint=False,
|
|
328
|
+
destructiveHint=True,
|
|
329
|
+
),
|
|
330
|
+
)
|
|
331
|
+
def fix(path: str, findings_json: FindingsInput, in_place: bool = False) -> Any:
|
|
332
|
+
"""Generate and verify fixes for scan findings.
|
|
333
|
+
|
|
334
|
+
By default this returns a unified diff and does not touch any files. Set
|
|
335
|
+
``in_place=True`` to write the patches to the source files. Each patch is
|
|
336
|
+
verified by re-scanning the patched code. This tool needs the FRAME_LLM_*
|
|
337
|
+
environment variables (FRAME_LLM_BASE_URL, FRAME_LLM_MODEL, and an API key
|
|
338
|
+
when the endpoint requires one).
|
|
339
|
+
"""
|
|
340
|
+
findings_file = _write_findings_tempfile(findings_json)
|
|
341
|
+
try:
|
|
342
|
+
args = _build_fix_args(path, findings_file, in_place=in_place)
|
|
343
|
+
return _run_frame(args, timeout=1800.0, ok_codes=(0, 1))
|
|
344
|
+
finally:
|
|
345
|
+
_safe_unlink(findings_file)
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
@mcp.tool(
|
|
349
|
+
annotations=ToolAnnotations(
|
|
350
|
+
title="Drive an exploitation agent against a target",
|
|
351
|
+
readOnlyHint=False,
|
|
352
|
+
destructiveHint=True,
|
|
353
|
+
openWorldHint=True,
|
|
354
|
+
),
|
|
355
|
+
)
|
|
356
|
+
def exploit(
|
|
357
|
+
target: str,
|
|
358
|
+
findings_json: Optional[FindingsInput] = None,
|
|
359
|
+
goal: Optional[str] = None,
|
|
360
|
+
success_check: Optional[str] = None,
|
|
361
|
+
max_steps: Optional[int] = None,
|
|
362
|
+
) -> Any:
|
|
363
|
+
"""Drive an LLM agent to exploit a live target. Authorized use only.
|
|
364
|
+
|
|
365
|
+
Run this only against systems you own or are explicitly authorized to
|
|
366
|
+
test. ``target`` is a URL such as http://app:8080. Optionally prime the
|
|
367
|
+
agent with ``findings_json`` from ``scan``, a plain-language ``goal``, a
|
|
368
|
+
``success_check`` shell command (exit 0 means solved), and ``max_steps``.
|
|
369
|
+
Needs the FRAME_LLM_* environment variables.
|
|
370
|
+
"""
|
|
371
|
+
findings_file = (
|
|
372
|
+
_write_findings_tempfile(findings_json) if findings_json is not None else None
|
|
373
|
+
)
|
|
374
|
+
try:
|
|
375
|
+
args = _build_exploit_args(
|
|
376
|
+
target,
|
|
377
|
+
guidance_file=findings_file,
|
|
378
|
+
goal=goal,
|
|
379
|
+
success_check=success_check,
|
|
380
|
+
max_steps=max_steps,
|
|
381
|
+
)
|
|
382
|
+
return _run_frame(args, timeout=1800.0, ok_codes=(0, 1))
|
|
383
|
+
finally:
|
|
384
|
+
if findings_file is not None:
|
|
385
|
+
_safe_unlink(findings_file)
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
@mcp.tool(
|
|
389
|
+
annotations=ToolAnnotations(title="List loadable framework packs", readOnlyHint=True),
|
|
390
|
+
)
|
|
391
|
+
def packs_list(path: Optional[str] = None) -> Any:
|
|
392
|
+
"""List the framework packs a scan would load.
|
|
393
|
+
|
|
394
|
+
Packs teach Frame a framework's sources, sinks, sanitizers and entry
|
|
395
|
+
points. Pass ``path`` to include a project directory's .frame/packs.
|
|
396
|
+
"""
|
|
397
|
+
args = _build_packs_list_args(path)
|
|
398
|
+
return _run_frame(args, timeout=60.0, ok_codes=(0, 1))
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
@mcp.tool(
|
|
402
|
+
annotations=ToolAnnotations(title="Validate framework pack files", readOnlyHint=True),
|
|
403
|
+
)
|
|
404
|
+
def packs_check(files: list[str]) -> Any:
|
|
405
|
+
"""Validate one or more framework pack .toml files or directories."""
|
|
406
|
+
args = _build_packs_check_args(files)
|
|
407
|
+
return _run_frame(args, timeout=60.0, ok_codes=(0, 1))
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
@mcp.tool(
|
|
411
|
+
annotations=ToolAnnotations(title="Check a separation logic entailment", readOnlyHint=True),
|
|
412
|
+
)
|
|
413
|
+
def solve(entailment: str, model: bool = False) -> Any:
|
|
414
|
+
"""Check whether a separation logic entailment ``P |- Q`` is valid.
|
|
415
|
+
|
|
416
|
+
Example entailment: ``x |-> 5 |- x |-> 5``. Set ``model=True`` to return a
|
|
417
|
+
countermodel when the entailment is invalid.
|
|
418
|
+
"""
|
|
419
|
+
args = _build_solve_args(entailment, model=model)
|
|
420
|
+
return _run_frame(args, timeout=60.0, ok_codes=(0, 1))
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
def _safe_unlink(path: str) -> None:
|
|
424
|
+
try:
|
|
425
|
+
os.unlink(path)
|
|
426
|
+
except OSError:
|
|
427
|
+
pass
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
# --------------------------------------------------------------------------
|
|
431
|
+
# prompt
|
|
432
|
+
# --------------------------------------------------------------------------
|
|
433
|
+
@mcp.prompt(name="security-review")
|
|
434
|
+
def security_review(path: str) -> str:
|
|
435
|
+
"""Scan a project with the AI layer, verify, then offer to fix."""
|
|
436
|
+
return (
|
|
437
|
+
f"Review the code at '{path}' for security vulnerabilities.\n\n"
|
|
438
|
+
"1. Call the 'scan' tool with path set to this location and ai=true to "
|
|
439
|
+
"run taint analysis plus the LLM detection and triage layer.\n"
|
|
440
|
+
"2. Pass the scan result to the 'verify' tool to confirm which findings "
|
|
441
|
+
"are still present.\n"
|
|
442
|
+
"3. Summarize each confirmed finding (CWE, file, line, data flow). For "
|
|
443
|
+
"findings that remain present, offer to call the 'fix' tool, which "
|
|
444
|
+
"returns a verified diff by default (or writes changes with "
|
|
445
|
+
"in_place=true). Do not fix anything without the user's go-ahead."
|
|
446
|
+
)
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
def main() -> None:
|
|
450
|
+
"""Console-script entry point: run the stdio MCP server."""
|
|
451
|
+
mcp.run()
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
if __name__ == "__main__":
|
|
455
|
+
main()
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"""Unit tests for frame-mcp argument building. No network, no subprocess."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import unittest
|
|
6
|
+
|
|
7
|
+
from frame_mcp import server
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ScanArgsTest(unittest.TestCase):
|
|
11
|
+
def test_minimal_defaults(self):
|
|
12
|
+
args = server._build_scan_args("/code")
|
|
13
|
+
self.assertEqual(
|
|
14
|
+
args, ["scan", "/code", "-f", "json", "--fail-on", "none"]
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
def test_all_options(self):
|
|
18
|
+
args = server._build_scan_args(
|
|
19
|
+
"/code",
|
|
20
|
+
language="python",
|
|
21
|
+
ai=True,
|
|
22
|
+
changed_ref="HEAD~1",
|
|
23
|
+
files=["a.py", "b.py"],
|
|
24
|
+
baseline="base.json",
|
|
25
|
+
min_severity="high",
|
|
26
|
+
fail_on="critical",
|
|
27
|
+
root="/root",
|
|
28
|
+
no_cross_file=True,
|
|
29
|
+
packs=["p1.toml", "p2.toml"],
|
|
30
|
+
)
|
|
31
|
+
self.assertEqual(
|
|
32
|
+
args,
|
|
33
|
+
[
|
|
34
|
+
"scan", "/code", "-f", "json", "--fail-on", "critical",
|
|
35
|
+
"-l", "python",
|
|
36
|
+
"--ai",
|
|
37
|
+
"--changed", "HEAD~1",
|
|
38
|
+
"--files", "a.py", "b.py",
|
|
39
|
+
"--baseline", "base.json",
|
|
40
|
+
"--min-severity", "high",
|
|
41
|
+
"--root", "/root",
|
|
42
|
+
"--no-cross-file",
|
|
43
|
+
"--pack", "p1.toml",
|
|
44
|
+
"--pack", "p2.toml",
|
|
45
|
+
],
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
def test_changed_ref_empty_string_included(self):
|
|
49
|
+
# An empty ref is meaningful (frame treats --changed with no value as HEAD).
|
|
50
|
+
args = server._build_scan_args("/code", changed_ref="")
|
|
51
|
+
self.assertIn("--changed", args)
|
|
52
|
+
self.assertEqual(args[args.index("--changed") + 1], "")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class WriteBaselineArgsTest(unittest.TestCase):
|
|
56
|
+
def test_args(self):
|
|
57
|
+
self.assertEqual(
|
|
58
|
+
server._build_write_baseline_args("/code", "b.json"),
|
|
59
|
+
["scan", "/code", "--write-baseline", "b.json", "--fail-on", "none"],
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class VerifyArgsTest(unittest.TestCase):
|
|
64
|
+
def test_no_ids(self):
|
|
65
|
+
self.assertEqual(
|
|
66
|
+
server._build_verify_args("f.json"),
|
|
67
|
+
["verify", "f.json", "-f", "json"],
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
def test_with_ids(self):
|
|
71
|
+
self.assertEqual(
|
|
72
|
+
server._build_verify_args("-", ids=["aa", "bb"]),
|
|
73
|
+
["verify", "-", "-f", "json", "--id", "aa", "--id", "bb"],
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class FixArgsTest(unittest.TestCase):
|
|
78
|
+
def test_default_diff(self):
|
|
79
|
+
args = server._build_fix_args("/code", "g.json")
|
|
80
|
+
self.assertEqual(
|
|
81
|
+
args, ["fix", "/code", "--guidance", "g.json", "--format", "json"]
|
|
82
|
+
)
|
|
83
|
+
self.assertNotIn("--in-place", args)
|
|
84
|
+
|
|
85
|
+
def test_in_place(self):
|
|
86
|
+
args = server._build_fix_args("/code", "g.json", in_place=True)
|
|
87
|
+
self.assertIn("--in-place", args)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class ExploitArgsTest(unittest.TestCase):
|
|
91
|
+
def test_minimal(self):
|
|
92
|
+
self.assertEqual(
|
|
93
|
+
server._build_exploit_args("http://app:8080"),
|
|
94
|
+
["exploit", "--target", "http://app:8080", "--format", "json"],
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
def test_full(self):
|
|
98
|
+
args = server._build_exploit_args(
|
|
99
|
+
"http://app:8080",
|
|
100
|
+
guidance_file="g.json",
|
|
101
|
+
goal="read a secret",
|
|
102
|
+
success_check="test -f /tmp/pwned",
|
|
103
|
+
max_steps=10,
|
|
104
|
+
)
|
|
105
|
+
self.assertEqual(
|
|
106
|
+
args,
|
|
107
|
+
[
|
|
108
|
+
"exploit", "--target", "http://app:8080", "--format", "json",
|
|
109
|
+
"--guidance", "g.json",
|
|
110
|
+
"--goal", "read a secret",
|
|
111
|
+
"--success-check", "test -f /tmp/pwned",
|
|
112
|
+
"--max-steps", "10",
|
|
113
|
+
],
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class SolveArgsTest(unittest.TestCase):
|
|
118
|
+
def test_no_model(self):
|
|
119
|
+
self.assertEqual(
|
|
120
|
+
server._build_solve_args("x |-> 5 |- x |-> 5"),
|
|
121
|
+
["solve", "x |-> 5 |- x |-> 5", "--format", "json"],
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
def test_with_model(self):
|
|
125
|
+
self.assertEqual(
|
|
126
|
+
server._build_solve_args("emp |- x |-> 5", model=True),
|
|
127
|
+
["solve", "emp |- x |-> 5", "--format", "json", "--model"],
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class PacksArgsTest(unittest.TestCase):
|
|
132
|
+
def test_list_no_path(self):
|
|
133
|
+
self.assertEqual(server._build_packs_list_args(), ["packs", "list"])
|
|
134
|
+
|
|
135
|
+
def test_list_with_path(self):
|
|
136
|
+
self.assertEqual(
|
|
137
|
+
server._build_packs_list_args("/proj"),
|
|
138
|
+
["packs", "list", "--project", "/proj"],
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
def test_check(self):
|
|
142
|
+
self.assertEqual(
|
|
143
|
+
server._build_packs_check_args(["a.toml", "b.toml"]),
|
|
144
|
+
["packs", "check", "a.toml", "b.toml"],
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
class FindingsTempfileTest(unittest.TestCase):
|
|
149
|
+
def test_dict_written_as_json(self):
|
|
150
|
+
path = server._write_findings_tempfile({"schema_version": 1, "files": []})
|
|
151
|
+
try:
|
|
152
|
+
with open(path, encoding="utf-8") as fh:
|
|
153
|
+
data = json.load(fh)
|
|
154
|
+
self.assertEqual(data["schema_version"], 1)
|
|
155
|
+
finally:
|
|
156
|
+
os.unlink(path)
|
|
157
|
+
|
|
158
|
+
def test_string_passthrough(self):
|
|
159
|
+
raw = '{"a": 1}'
|
|
160
|
+
path = server._write_findings_tempfile(raw)
|
|
161
|
+
try:
|
|
162
|
+
with open(path, encoding="utf-8") as fh:
|
|
163
|
+
self.assertEqual(fh.read(), raw)
|
|
164
|
+
finally:
|
|
165
|
+
os.unlink(path)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
class ParseOutputTest(unittest.TestCase):
|
|
169
|
+
class _Proc:
|
|
170
|
+
def __init__(self, stdout, stderr="", returncode=0):
|
|
171
|
+
self.stdout = stdout
|
|
172
|
+
self.stderr = stderr
|
|
173
|
+
self.returncode = returncode
|
|
174
|
+
|
|
175
|
+
def test_json_parsed(self):
|
|
176
|
+
out = server._parse_output(self._Proc('{"ok": true}'))
|
|
177
|
+
self.assertEqual(out, {"ok": True})
|
|
178
|
+
|
|
179
|
+
def test_non_json_fallback(self):
|
|
180
|
+
out = server._parse_output(self._Proc("not json", stderr="boom", returncode=1))
|
|
181
|
+
self.assertEqual(out["stdout"], "not json")
|
|
182
|
+
self.assertEqual(out["stderr"], "boom")
|
|
183
|
+
self.assertEqual(out["exit_code"], 1)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
class FrameExecutableTest(unittest.TestCase):
|
|
187
|
+
def test_returns_string(self):
|
|
188
|
+
self.assertIsInstance(server._frame_executable(), str)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
if __name__ == "__main__":
|
|
192
|
+
unittest.main()
|