@principlebreach/scopedown-mcp 1.0.1 → 1.0.2
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/package.json +1 -1
- package/src/client.js +3 -1
- package/src/framing.js +6 -2
- package/src/host.js +9 -5
- package/src/server.js +2 -2
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -110,7 +110,9 @@ export class Bridge {
|
|
|
110
110
|
if (!all.length) {
|
|
111
111
|
throw new BridgeError('no_browser', 'No browser is connected. Open the browser where you use HackerOne or Bugcrowd, click the ScopeDown icon, and switch Agents on.');
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
// Socket names follow the host's process id, which changes when a browser restarts. The
|
|
114
|
+
// install id does not, so the default browser (and the drafts it holds) stays the same.
|
|
115
|
+
if (!browser) return all.reduce((a, b) => (String(b.extension.install) < String(a.extension.install) ? b : a));
|
|
114
116
|
const want = browser.toLowerCase();
|
|
115
117
|
const match = all.find((l) => [l.extension.install, l.extension.browser].some((v) => String(v || '').toLowerCase() === want));
|
|
116
118
|
if (!match) throw new BridgeError('unknown_browser', `No connected browser called "${browser}". Connected: ${all.map(label).join(', ')}.`);
|
package/src/framing.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { StringDecoder } from 'node:string_decoder';
|
|
2
|
+
|
|
1
3
|
// Wire formats.
|
|
2
4
|
// Native messaging (browser <-> host): each message is a 32-bit length in native byte order
|
|
3
5
|
// (little-endian on every platform browsers ship on) followed by UTF-8 JSON.
|
|
@@ -36,11 +38,13 @@ export function encodeLine(message) {
|
|
|
36
38
|
return `${JSON.stringify(message)}\n`;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
// Feeds chunks in, calls onMessage for every complete JSON line.
|
|
41
|
+
// Feeds chunks in, calls onMessage for every complete JSON line. A read can end inside a
|
|
42
|
+
// multi-byte character, so the decoder carries those bytes over to the next chunk.
|
|
40
43
|
export function lineDecoder(onMessage, onError = () => {}) {
|
|
44
|
+
const utf8 = new StringDecoder('utf8');
|
|
41
45
|
let pending = '';
|
|
42
46
|
return (chunk) => {
|
|
43
|
-
pending += chunk.
|
|
47
|
+
pending += typeof chunk === 'string' ? chunk : utf8.write(chunk);
|
|
44
48
|
let newline;
|
|
45
49
|
while ((newline = pending.indexOf('\n')) >= 0) {
|
|
46
50
|
const line = pending.slice(0, newline).trim();
|
package/src/host.js
CHANGED
|
@@ -10,6 +10,14 @@ import { join } from 'node:path';
|
|
|
10
10
|
import { encodeNative, nativeDecoder, encodeLine, lineDecoder } from './framing.js';
|
|
11
11
|
import { scopedownHome, socketsDir, socketPath, logFile } from './paths.js';
|
|
12
12
|
|
|
13
|
+
// The sockets folder holds the Unix sockets, and on every OS the marker files that tell the
|
|
14
|
+
// MCP server where each host listens (on Windows the markers are the only way to find a pipe).
|
|
15
|
+
export function prepareDirs(os = platform()) {
|
|
16
|
+
mkdirSync(scopedownHome(), { recursive: true, mode: 0o700 });
|
|
17
|
+
mkdirSync(socketsDir(), { recursive: true, mode: 0o700 });
|
|
18
|
+
if (os !== 'win32') chmodSync(socketsDir(), 0o700);
|
|
19
|
+
}
|
|
20
|
+
|
|
13
21
|
export function runHost({ stdin = process.stdin, stdout = process.stdout } = {}) {
|
|
14
22
|
const log = (msg) => {
|
|
15
23
|
try {
|
|
@@ -17,11 +25,7 @@ export function runHost({ stdin = process.stdin, stdout = process.stdout } = {})
|
|
|
17
25
|
} catch { /* logging is best effort */ }
|
|
18
26
|
};
|
|
19
27
|
|
|
20
|
-
|
|
21
|
-
if (platform() !== 'win32') {
|
|
22
|
-
mkdirSync(socketsDir(), { recursive: true, mode: 0o700 });
|
|
23
|
-
chmodSync(socketsDir(), 0o700);
|
|
24
|
-
}
|
|
28
|
+
prepareDirs();
|
|
25
29
|
|
|
26
30
|
const name = `host-${process.pid}`;
|
|
27
31
|
const path = socketPath(name);
|
package/src/server.js
CHANGED
|
@@ -93,7 +93,7 @@ export function createServer(bridge = new Bridge()) {
|
|
|
93
93
|
|
|
94
94
|
readTool('list_programs', {
|
|
95
95
|
title: 'List programs',
|
|
96
|
-
description: 'Lists programs the user can submit reports to. private_only shows private invitations; query searches by name or handle. Each platform returns its own next_cursor; to page, pass platform with that cursor.',
|
|
96
|
+
description: 'Lists programs the user can submit reports to. private_only shows private invitations; query searches by name or handle. Each platform returns its own next_cursor; to page, pass platform with that cursor until it is null. A page can hold fewer than limit programs and still have a next_cursor.',
|
|
97
97
|
inputSchema: {
|
|
98
98
|
platform: platform.optional().describe('Limit to one platform. Default: both.'),
|
|
99
99
|
private_only: z.boolean().optional().describe('Only private programs the user was invited to.'),
|
|
@@ -142,7 +142,7 @@ export function createServer(bridge = new Bridge()) {
|
|
|
142
142
|
|
|
143
143
|
readTool('get_my_report', {
|
|
144
144
|
title: 'Get one of my reports',
|
|
145
|
-
description: 'Returns one of the user\'s reports with its state, severity and the comment thread, so you can see what triage asked for. Long threads page with thread_cursor. Supported where status shows report_threads (HackerOne).',
|
|
145
|
+
description: 'Returns one of the user\'s reports with its state, severity and the comment thread, so you can see what triage asked for. Long threads page with thread_cursor. A disclosed report by someone else can be read too: check yours, which is true only for the user\'s own reports. A limited disclosure has no description; its summaries hold what was published. Supported where status shows report_threads (HackerOne).',
|
|
146
146
|
inputSchema: {
|
|
147
147
|
platform,
|
|
148
148
|
id: z.string().regex(/^[\w-]{1,40}$/).describe('Report id, as in hackerone.com/reports/<id>.'),
|