bomly-mcp 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +7 -0
- package/README.md +65 -0
- package/bin/bomly-mcp.js +62 -0
- package/package.json +53 -0
- package/scripts/postinstall.js +184 -0
- package/scripts/prepack.js +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 bomly.dev
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<!-- mcp-name: io.github.bomly-dev/bomly-cli -->
|
|
2
|
+
|
|
3
|
+
# bomly-mcp
|
|
4
|
+
|
|
5
|
+
Give your coding agent the dependency graph it is about to change.
|
|
6
|
+
|
|
7
|
+
`bomly-mcp` starts the [Bomly](https://github.com/bomly-dev/bomly-cli) MCP server over stdio, so an MCP-aware agent can generate, diff, explain, and audit dependencies itself instead of asking you to paste scan output into chat.
|
|
8
|
+
|
|
9
|
+
Free and open source, no account, no login.
|
|
10
|
+
|
|
11
|
+
## Use it
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx -y bomly-mcp
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Claude Code:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
claude mcp add --transport stdio bomly -- npx -y bomly-mcp
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Cursor or VS Code, in `.cursor/mcp.json` or `.vscode/mcp.json`:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"mcpServers": {
|
|
28
|
+
"bomly": {
|
|
29
|
+
"type": "stdio",
|
|
30
|
+
"command": "npx",
|
|
31
|
+
"args": ["-y", "bomly-mcp"]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
If you already have the `bomly` CLI on `PATH`, you do not need this package — point your client at `bomly mcp serve` instead.
|
|
38
|
+
|
|
39
|
+
## Tools
|
|
40
|
+
|
|
41
|
+
| Tool | Use it for |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `bomly_scan` | Scan a path, Git URL, container image, or SBOM and return a compact dependency summary. |
|
|
44
|
+
| `bomly_explain` | Show why one package is present, with full advisory details when enriched. |
|
|
45
|
+
| `bomly_diff` | Compare dependencies between Git refs, container images, or SBOM files. |
|
|
46
|
+
| `bomly_plugins` | List built-in and installed plugins with their enabled state. |
|
|
47
|
+
|
|
48
|
+
Full setup, arguments, and troubleshooting: [docs/MCP.md](https://github.com/bomly-dev/bomly-cli/blob/main/docs/MCP.md).
|
|
49
|
+
|
|
50
|
+
## How it installs
|
|
51
|
+
|
|
52
|
+
The postinstall step downloads the Bomly release archive for your platform from GitHub Releases, checks it against that release's `SHA256SUMS`, and unpacks the binary into the package. A checksum mismatch fails the install; there is no unverified fallback.
|
|
53
|
+
|
|
54
|
+
Environment overrides:
|
|
55
|
+
|
|
56
|
+
- `BOMLY_MCP_VERSION` — download a different CLI version.
|
|
57
|
+
- `BOMLY_MCP_SKIP_DOWNLOAD=1` — skip the download (for lint or CI installs that never run the server).
|
|
58
|
+
|
|
59
|
+
Supported: macOS, Linux, and Windows on x64 and arm64.
|
|
60
|
+
|
|
61
|
+
## Network behavior
|
|
62
|
+
|
|
63
|
+
The server runs as you, on your machine, and reads the project files the Bomly process can read. Vulnerability, license, lifecycle, and scorecard lookups are opt-in per call via `enrich`. Some detectors invoke package-manager commands, and those tools can contact package registries as part of normal dependency resolution. See [Detectors](https://github.com/bomly-dev/bomly-cli/blob/main/docs/DETECTORS.md#network-behavior).
|
|
64
|
+
|
|
65
|
+
Apache-2.0.
|
package/bin/bomly-mcp.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Starts the Bomly MCP server over stdio.
|
|
3
|
+
//
|
|
4
|
+
// This process must stay transparent: stdout carries the JSON-RPC stream and
|
|
5
|
+
// nothing else. Diagnostics go to stderr, which is where `bomly mcp serve`
|
|
6
|
+
// already writes its startup banner.
|
|
7
|
+
|
|
8
|
+
"use strict";
|
|
9
|
+
|
|
10
|
+
const { spawn } = require("node:child_process");
|
|
11
|
+
const fs = require("node:fs");
|
|
12
|
+
const path = require("node:path");
|
|
13
|
+
|
|
14
|
+
const binary = process.platform === "win32" ? "bomly.exe" : "bomly";
|
|
15
|
+
const vendored = path.join(__dirname, "..", "vendor", binary);
|
|
16
|
+
|
|
17
|
+
if (!fs.existsSync(vendored)) {
|
|
18
|
+
console.error(
|
|
19
|
+
"bomly-mcp: the Bomly binary is missing. Reinstall the package so its postinstall step can run:\n" +
|
|
20
|
+
" npm install bomly-mcp\n" +
|
|
21
|
+
"Or install the CLI directly and run `bomly mcp serve` instead:\n" +
|
|
22
|
+
" https://github.com/bomly-dev/bomly-cli/blob/main/docs/INSTALLATION.md",
|
|
23
|
+
);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const child = spawn(vendored, ["mcp", "serve", ...process.argv.slice(2)], {
|
|
28
|
+
stdio: "inherit",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
child.on("error", (error) => {
|
|
32
|
+
console.error(`bomly-mcp: could not start ${vendored}: ${error.message}`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Forward the signals an MCP client uses to stop a stdio server, so the child
|
|
37
|
+
// shuts down with us rather than being orphaned.
|
|
38
|
+
const forwarders = new Map();
|
|
39
|
+
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
|
|
40
|
+
const forward = () => child.kill(signal);
|
|
41
|
+
forwarders.set(signal, forward);
|
|
42
|
+
process.on(signal, forward);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
child.on("exit", (code, signal) => {
|
|
46
|
+
if (signal) {
|
|
47
|
+
// Adding a listener above replaced Node's default terminate-on-signal
|
|
48
|
+
// behavior. Re-raising while it is still attached only re-enters our own
|
|
49
|
+
// handler; the event loop then drains and we exit 0 — telling whatever
|
|
50
|
+
// supervises us that the server shut down cleanly when it was actually
|
|
51
|
+
// killed. Removing the listener first lets the signal reach the default
|
|
52
|
+
// handler, so we die of the same cause the child did. process.exit is the
|
|
53
|
+
// backstop for platforms where re-raising does not terminate us.
|
|
54
|
+
const forward = forwarders.get(signal);
|
|
55
|
+
if (forward) {
|
|
56
|
+
process.removeListener(signal, forward);
|
|
57
|
+
}
|
|
58
|
+
process.kill(process.pid, signal);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
process.exit(code === null ? 1 : code);
|
|
62
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bomly-mcp",
|
|
3
|
+
"version": "0.21.1",
|
|
4
|
+
"description": "Run the Bomly MCP server with npx. Downloads the matching Bomly CLI release binary and starts `bomly mcp serve`.",
|
|
5
|
+
"mcpName": "io.github.bomly-dev/bomly-cli",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"author": "Ahmed ElMallah <ahmed@bomly.dev>",
|
|
8
|
+
"homepage": "https://bomly.dev/cli",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/bomly-dev/bomly-cli.git",
|
|
12
|
+
"directory": "npm"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/bomly-dev/bomly-cli/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"mcp",
|
|
19
|
+
"model-context-protocol",
|
|
20
|
+
"sbom",
|
|
21
|
+
"dependencies",
|
|
22
|
+
"cyclonedx",
|
|
23
|
+
"spdx",
|
|
24
|
+
"bomly"
|
|
25
|
+
],
|
|
26
|
+
"bin": {
|
|
27
|
+
"bomly-mcp": "bin/bomly-mcp.js"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"bin/",
|
|
31
|
+
"scripts/",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"NOTICE"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18"
|
|
38
|
+
},
|
|
39
|
+
"os": [
|
|
40
|
+
"darwin",
|
|
41
|
+
"linux",
|
|
42
|
+
"win32"
|
|
43
|
+
],
|
|
44
|
+
"cpu": [
|
|
45
|
+
"x64",
|
|
46
|
+
"arm64"
|
|
47
|
+
],
|
|
48
|
+
"scripts": {
|
|
49
|
+
"prepack": "node scripts/prepack.js",
|
|
50
|
+
"postinstall": "node scripts/postinstall.js",
|
|
51
|
+
"test": "node --test \"test/*.test.js\""
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Downloads the Bomly CLI release archive that matches this package version,
|
|
3
|
+
// verifies it against the release's SHA256SUMS, and unpacks the `bomly`
|
|
4
|
+
// binary into vendor/. bin/bomly-mcp.js then execs that binary.
|
|
5
|
+
//
|
|
6
|
+
// The download is verified or it fails. There is no unverified fallback.
|
|
7
|
+
|
|
8
|
+
"use strict";
|
|
9
|
+
|
|
10
|
+
const { createHash } = require("node:crypto");
|
|
11
|
+
const { execFileSync } = require("node:child_process");
|
|
12
|
+
const fs = require("node:fs");
|
|
13
|
+
const os = require("node:os");
|
|
14
|
+
const path = require("node:path");
|
|
15
|
+
|
|
16
|
+
const pkg = require("../package.json");
|
|
17
|
+
|
|
18
|
+
const ROOT = path.join(__dirname, "..");
|
|
19
|
+
const VENDOR_DIR = path.join(ROOT, "vendor");
|
|
20
|
+
const RELEASE_BASE = "https://github.com/bomly-dev/bomly-cli/releases/download";
|
|
21
|
+
|
|
22
|
+
// Same names GoReleaser writes: bomly_<version>_<goos>_<goarch>.<tar.gz|zip>.
|
|
23
|
+
const GOOS = { darwin: "darwin", linux: "linux", win32: "windows" };
|
|
24
|
+
const GOARCH = { x64: "amd64", arm64: "arm64" };
|
|
25
|
+
|
|
26
|
+
function fail(message) {
|
|
27
|
+
console.error(`bomly-mcp: ${message}`);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Throws rather than exiting so it stays testable; main() turns the throw
|
|
32
|
+
// into the user-facing message.
|
|
33
|
+
function resolveTarget(platform, arch) {
|
|
34
|
+
const goos = GOOS[platform];
|
|
35
|
+
const goarch = GOARCH[arch];
|
|
36
|
+
if (!goos || !goarch) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
`no Bomly release build for ${platform}/${arch}. ` +
|
|
39
|
+
"Install the CLI another way (https://github.com/bomly-dev/bomly-cli/blob/main/docs/INSTALLATION.md) " +
|
|
40
|
+
"and point your MCP client at `bomly mcp serve`.",
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
const ext = goos === "windows" ? "zip" : "tar.gz";
|
|
44
|
+
return { goos, goarch, ext, binary: goos === "windows" ? "bomly.exe" : "bomly" };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Same names GoReleaser writes.
|
|
48
|
+
function archiveNameFor(version, goos, goarch, ext) {
|
|
49
|
+
return `bomly_${version}_${goos}_${goarch}.${ext}`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function download(url) {
|
|
53
|
+
const response = await fetch(url, { redirect: "follow" });
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
fail(`GET ${url} returned HTTP ${response.status}`);
|
|
56
|
+
}
|
|
57
|
+
return Buffer.from(await response.arrayBuffer());
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function sha256(buffer) {
|
|
61
|
+
return createHash("sha256").update(buffer).digest("hex");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// SHA256SUMS is `<hex> <filename>` per line, as produced by GoReleaser.
|
|
65
|
+
function expectedSum(sums, filename) {
|
|
66
|
+
for (const line of sums.split("\n")) {
|
|
67
|
+
const [hex, name] = line.trim().split(/\s+/);
|
|
68
|
+
if (name === filename) {
|
|
69
|
+
return hex;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Written to disk and invoked with -File so the paths arrive as real argv
|
|
76
|
+
// entries. Interpolating them into a -Command string breaks on any path
|
|
77
|
+
// holding an apostrophe (C:\Users\O'Brien\...) and would let a path influence
|
|
78
|
+
// the command itself.
|
|
79
|
+
const EXPAND_PS1 = `param(
|
|
80
|
+
[Parameter(Mandatory=$true)][string]$Archive,
|
|
81
|
+
[Parameter(Mandatory=$true)][string]$Destination
|
|
82
|
+
)
|
|
83
|
+
$ErrorActionPreference = 'Stop'
|
|
84
|
+
Expand-Archive -LiteralPath $Archive -DestinationPath $Destination -Force
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
function unpack(archivePath, destination, ext) {
|
|
88
|
+
if (ext === "zip") {
|
|
89
|
+
// PowerShell ships with every supported Windows version; `tar` does too on
|
|
90
|
+
// Windows 10 1803+, but Expand-Archive is the safer floor for zip.
|
|
91
|
+
const scriptPath = path.join(destination, "expand.ps1");
|
|
92
|
+
fs.writeFileSync(scriptPath, EXPAND_PS1);
|
|
93
|
+
execFileSync(
|
|
94
|
+
"powershell",
|
|
95
|
+
[
|
|
96
|
+
"-NoProfile",
|
|
97
|
+
"-NonInteractive",
|
|
98
|
+
"-ExecutionPolicy",
|
|
99
|
+
"Bypass",
|
|
100
|
+
"-File",
|
|
101
|
+
scriptPath,
|
|
102
|
+
"-Archive",
|
|
103
|
+
archivePath,
|
|
104
|
+
"-Destination",
|
|
105
|
+
destination,
|
|
106
|
+
],
|
|
107
|
+
{ stdio: "inherit" },
|
|
108
|
+
);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
execFileSync("tar", ["-xzf", archivePath, "-C", destination], { stdio: "inherit" });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// The release archive carries LICENSE, NOTICE, and a licenses/ tree of
|
|
115
|
+
// third-party license texts. Vendoring the binary without them would
|
|
116
|
+
// redistribute Bomly and its bundled components with the notices stripped.
|
|
117
|
+
function copyNotices(staging, destination) {
|
|
118
|
+
for (const entry of ["LICENSE", "NOTICE", "licenses"]) {
|
|
119
|
+
const from = path.join(staging, entry);
|
|
120
|
+
if (fs.existsSync(from)) {
|
|
121
|
+
fs.cpSync(from, path.join(destination, entry), { recursive: true });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function main() {
|
|
127
|
+
if (process.env.BOMLY_MCP_SKIP_DOWNLOAD === "1") {
|
|
128
|
+
console.error("bomly-mcp: BOMLY_MCP_SKIP_DOWNLOAD=1, skipping binary download.");
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const version = process.env.BOMLY_MCP_VERSION || pkg.version;
|
|
133
|
+
const { ext, goos, goarch, binary } = resolveTarget(process.platform, process.arch);
|
|
134
|
+
const archiveName = archiveNameFor(version, goos, goarch, ext);
|
|
135
|
+
const tag = `v${version}`;
|
|
136
|
+
|
|
137
|
+
const sums = (await download(`${RELEASE_BASE}/${tag}/SHA256SUMS`)).toString("utf8");
|
|
138
|
+
const expected = expectedSum(sums, archiveName);
|
|
139
|
+
if (!expected) {
|
|
140
|
+
fail(`${archiveName} is not listed in the SHA256SUMS for ${tag}`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const archive = await download(`${RELEASE_BASE}/${tag}/${archiveName}`);
|
|
144
|
+
const actual = sha256(archive);
|
|
145
|
+
if (actual !== expected) {
|
|
146
|
+
fail(
|
|
147
|
+
`checksum mismatch for ${archiveName}\n` +
|
|
148
|
+
` expected ${expected}\n` +
|
|
149
|
+
` actual ${actual}\n` +
|
|
150
|
+
"Refusing to install. Please report this at https://github.com/bomly-dev/bomly-cli/issues.",
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const staging = fs.mkdtempSync(path.join(os.tmpdir(), "bomly-mcp-"));
|
|
155
|
+
try {
|
|
156
|
+
const archivePath = path.join(staging, archiveName);
|
|
157
|
+
fs.writeFileSync(archivePath, archive);
|
|
158
|
+
unpack(archivePath, staging, ext);
|
|
159
|
+
|
|
160
|
+
const extracted = path.join(staging, binary);
|
|
161
|
+
if (!fs.existsSync(extracted)) {
|
|
162
|
+
fail(`${archiveName} did not contain ${binary}`);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
fs.mkdirSync(VENDOR_DIR, { recursive: true });
|
|
166
|
+
const installed = path.join(VENDOR_DIR, binary);
|
|
167
|
+
fs.copyFileSync(extracted, installed);
|
|
168
|
+
if (goos !== "windows") {
|
|
169
|
+
fs.chmodSync(installed, 0o755);
|
|
170
|
+
}
|
|
171
|
+
copyNotices(staging, VENDOR_DIR);
|
|
172
|
+
console.error(`bomly-mcp: installed bomly ${version} (${goos}/${goarch}), checksum verified.`);
|
|
173
|
+
} finally {
|
|
174
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (require.main === module) {
|
|
179
|
+
main().catch((error) => fail(error && error.message ? error.message : String(error)));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Exported for test/. Everything here is pure or filesystem-local; the
|
|
183
|
+
// network path is exercised end to end by installing a packed tarball.
|
|
184
|
+
module.exports = { resolveTarget, archiveNameFor, expectedSum, sha256, unpack, copyNotices };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Copies the repository LICENSE and NOTICE into the package before it is
|
|
3
|
+
// packed, so the published tarball carries them.
|
|
4
|
+
//
|
|
5
|
+
// They are copied rather than committed here because a second copy in git
|
|
6
|
+
// drifts from the originals. `files` in package.json lists them, and
|
|
7
|
+
// .gitignore ignores them inside npm/.
|
|
8
|
+
|
|
9
|
+
"use strict";
|
|
10
|
+
|
|
11
|
+
const fs = require("node:fs");
|
|
12
|
+
const path = require("node:path");
|
|
13
|
+
|
|
14
|
+
const PACKAGE_DIR = path.join(__dirname, "..");
|
|
15
|
+
const REPO_ROOT = path.join(PACKAGE_DIR, "..");
|
|
16
|
+
|
|
17
|
+
for (const name of ["LICENSE", "NOTICE"]) {
|
|
18
|
+
const from = path.join(REPO_ROOT, name);
|
|
19
|
+
if (!fs.existsSync(from)) {
|
|
20
|
+
console.error(
|
|
21
|
+
`bomly-mcp: ${name} is missing at the repository root. ` +
|
|
22
|
+
"The package must not be published without it.",
|
|
23
|
+
);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
fs.copyFileSync(from, path.join(PACKAGE_DIR, name));
|
|
27
|
+
}
|