@stealthmole/mcp 0.1.12 → 0.1.13
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/bin/claude-desktop-config.mjs +38 -0
- package/bin/cli.mjs +33 -20
- package/bin/node-version-guard.mjs +56 -0
- package/package.json +1 -1
|
@@ -27,6 +27,29 @@ const CONFIG_FILENAME = "claude_desktop_config.json";
|
|
|
27
27
|
/** npx specifier for the retired `stealthmole.mcp` package, with or without a version range. */
|
|
28
28
|
const RETIRED_PACKAGE_ARG = /^stealthmole\.mcp(@.+)?$/;
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* npx specifier for either package that launches this server.
|
|
32
|
+
*
|
|
33
|
+
* Deliberately wider than {@link RETIRED_PACKAGE_ARG}: that one drives the
|
|
34
|
+
* rewrite and must not touch an entry already on the scoped package, while this
|
|
35
|
+
* one only answers "is this entry ours".
|
|
36
|
+
*/
|
|
37
|
+
const SERVER_PACKAGE_ARG = /^(?:@stealthmole\/mcp|stealthmole\.mcp)(@.+)?$/;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Whether an `mcpServers` entry launches this server.
|
|
41
|
+
*
|
|
42
|
+
* Matched on `args`, not `command`: the command is `npx`, `npx.cmd`, or an
|
|
43
|
+
* absolute path depending on platform and install, while the package specifier
|
|
44
|
+
* is identical everywhere.
|
|
45
|
+
*
|
|
46
|
+
* @param {object} entry an `mcpServers` entry
|
|
47
|
+
* @returns {boolean}
|
|
48
|
+
*/
|
|
49
|
+
function launchesThisServer(entry) {
|
|
50
|
+
return Array.isArray(entry?.args) && entry.args.some((arg) => SERVER_PACKAGE_ARG.test(arg));
|
|
51
|
+
}
|
|
52
|
+
|
|
30
53
|
/**
|
|
31
54
|
* Repoint an entry's npx args at `@stealthmole/mcp`.
|
|
32
55
|
*
|
|
@@ -166,6 +189,21 @@ export function ensureClaudeDesktopConfig({
|
|
|
166
189
|
return "migrated";
|
|
167
190
|
}
|
|
168
191
|
|
|
192
|
+
// The customer may have registered this server by hand under a key of
|
|
193
|
+
// their own choosing. Identity is the package the entry launches, not the
|
|
194
|
+
// key it sits under — judging by key alone adds a SECOND entry, so the
|
|
195
|
+
// server runs twice, every tool shows up twice, and the entry we add
|
|
196
|
+
// carries none of their `env` (notably STEALTHMOLE_CLIENT_SECRET).
|
|
197
|
+
const foreignKey = Object.keys(servers).find((key) => launchesThisServer(servers[key]));
|
|
198
|
+
if (foreignKey) {
|
|
199
|
+
if (debug) {
|
|
200
|
+
console.error(
|
|
201
|
+
`${LOG_PREFIX} Already registered under "${foreignKey}", leaving it as is.`
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
return "unchanged";
|
|
205
|
+
}
|
|
206
|
+
|
|
169
207
|
servers[SERVER_KEY] = {
|
|
170
208
|
command: "npx",
|
|
171
209
|
args: ["-y", `@stealthmole/mcp@^${pkgVersion}`],
|
package/bin/cli.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { createServer } from "net";
|
|
|
7
7
|
import { readFileSync } from "fs";
|
|
8
8
|
|
|
9
9
|
import { ensureClaudeDesktopConfig } from "./claude-desktop-config.mjs";
|
|
10
|
+
import { unsupportedNodeMessage } from "./node-version-guard.mjs";
|
|
10
11
|
import { migrateTokenCache } from "./token-cache-shim.mjs";
|
|
11
12
|
|
|
12
13
|
// Read current package version for pinned auto-registration
|
|
@@ -14,6 +15,38 @@ const PKG_VERSION = JSON.parse(
|
|
|
14
15
|
readFileSync(new URL("../package.json", import.meta.url), "utf-8")
|
|
15
16
|
).version;
|
|
16
17
|
|
|
18
|
+
// --help and --version come first. Both are diagnostics a customer runs to
|
|
19
|
+
// report what they have installed, so nothing below may run ahead of them:
|
|
20
|
+
// a fresh registration exits the process, and argv filtering rewrites
|
|
21
|
+
// process.argv out from under them.
|
|
22
|
+
if (process.argv.includes("--help") || process.argv.includes("-h")) {
|
|
23
|
+
console.error(
|
|
24
|
+
`@stealthmole/mcp v${PKG_VERSION}\n` +
|
|
25
|
+
"\nUsage: npx -y @stealthmole/mcp [options]\n" +
|
|
26
|
+
"\nOptions:\n" +
|
|
27
|
+
" --port <number> Callback port for OAuth redirect\n" +
|
|
28
|
+
" --callback-port <number> Alias for --port\n" +
|
|
29
|
+
" --debug Enable debug logging\n" +
|
|
30
|
+
" --help, -h Show this help message\n" +
|
|
31
|
+
" --version, -v Show version number\n"
|
|
32
|
+
);
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (process.argv.includes("--version") || process.argv.includes("-v")) {
|
|
37
|
+
console.error(PKG_VERSION);
|
|
38
|
+
process.exit(0);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Refuse an unsupported Node before touching anything. Registering a config
|
|
42
|
+
// entry that cannot run is worse than not registering: Claude Desktop would
|
|
43
|
+
// keep launching a server that crashes inside node_modules.
|
|
44
|
+
const nodeProblem = unsupportedNodeMessage();
|
|
45
|
+
if (nodeProblem) {
|
|
46
|
+
console.error(nodeProblem);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
17
50
|
// Register (or migrate) the Claude Desktop entry before starting the proxy.
|
|
18
51
|
// A rename keeps running: Claude Desktop launched this process under the old
|
|
19
52
|
// key, so exiting would break the session the user is in right now.
|
|
@@ -37,26 +70,6 @@ const AUTH_SUCCESS_URL = "https://www.stealthmole.com/";
|
|
|
37
70
|
const CALLBACK_HOST = "localhost";
|
|
38
71
|
const DEBUG = process.argv.includes("--debug");
|
|
39
72
|
|
|
40
|
-
// Handle --help and --version before argv filtering
|
|
41
|
-
if (process.argv.includes("--help") || process.argv.includes("-h")) {
|
|
42
|
-
console.error(
|
|
43
|
-
`@stealthmole/mcp v${PKG_VERSION}\n` +
|
|
44
|
-
"\nUsage: npx -y @stealthmole/mcp [options]\n" +
|
|
45
|
-
"\nOptions:\n" +
|
|
46
|
-
" --port <number> Callback port for OAuth redirect\n" +
|
|
47
|
-
" --callback-port <number> Alias for --port\n" +
|
|
48
|
-
" --debug Enable debug logging\n" +
|
|
49
|
-
" --help, -h Show this help message\n" +
|
|
50
|
-
" --version, -v Show version number\n"
|
|
51
|
-
);
|
|
52
|
-
process.exit(0);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (process.argv.includes("--version") || process.argv.includes("-v")) {
|
|
56
|
-
console.error(PKG_VERSION);
|
|
57
|
-
process.exit(0);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
73
|
/**
|
|
61
74
|
* Find an available port not occupied by another process.
|
|
62
75
|
*
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Node.js version guard for the StealthMole MCP client.
|
|
2
|
+
//
|
|
3
|
+
// mcp-remote depends on undici, which dereferences the global `File` at require
|
|
4
|
+
// time (undici/lib/web/webidl/index.js). `File` became global in Node 20, so on
|
|
5
|
+
// Node 18 the proxy dies with `ReferenceError: File is not defined` and a stack
|
|
6
|
+
// trace through node_modules — the customer sees a crash, not a cause.
|
|
7
|
+
//
|
|
8
|
+
// `engines.node` does not prevent this: npm and npx print a warning and run
|
|
9
|
+
// anyway. The check has to happen at runtime.
|
|
10
|
+
|
|
11
|
+
import { readFileSync } from "fs";
|
|
12
|
+
|
|
13
|
+
const LOG_PREFIX = "[stealthmole-mcp]";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Node.js version declared in `engines.node`, for the install advice.
|
|
17
|
+
*
|
|
18
|
+
* Read from package.json so the number is written once. It mirrors undici's own
|
|
19
|
+
* `engines` and is only a recommendation here — the guard below refuses strictly
|
|
20
|
+
* less, because versions between 20.0.0 and this one still run fine (measured:
|
|
21
|
+
* 20.9.0 loads undici without error).
|
|
22
|
+
*/
|
|
23
|
+
export const RECOMMENDED_NODE_VERSION = JSON.parse(
|
|
24
|
+
readFileSync(new URL("../package.json", import.meta.url), "utf-8")
|
|
25
|
+
).engines.node.replace(/^[^\d]*/, "");
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Explain why this Node cannot run the client, or `null` when it can.
|
|
29
|
+
*
|
|
30
|
+
* Tests the missing global directly instead of comparing version numbers.
|
|
31
|
+
* A version range has to be guessed and then maintained as undici moves, and
|
|
32
|
+
* guessing it too high is the worse error: it would refuse customers who are
|
|
33
|
+
* working today. The global either exists or it does not.
|
|
34
|
+
*
|
|
35
|
+
* Returns the message rather than printing and exiting, so the decision to
|
|
36
|
+
* terminate stays with the caller and the rule stays unit-testable.
|
|
37
|
+
*
|
|
38
|
+
* @param {boolean} [hasFileGlobal] whether `File` is a global in this runtime
|
|
39
|
+
* @param {string} [current] version to name in the message
|
|
40
|
+
* @returns {string|null}
|
|
41
|
+
*/
|
|
42
|
+
export function unsupportedNodeMessage(
|
|
43
|
+
hasFileGlobal = typeof File !== "undefined",
|
|
44
|
+
current = process.versions.node
|
|
45
|
+
) {
|
|
46
|
+
if (hasFileGlobal) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
`${LOG_PREFIX} Node.js ${current} is too old: mcp-remote needs the global ` +
|
|
52
|
+
`"File", which Node.js added in version 20.\n` +
|
|
53
|
+
`${LOG_PREFIX} Install Node.js ${RECOMMENDED_NODE_VERSION} or newer from ` +
|
|
54
|
+
`https://nodejs.org/ and restart Claude Desktop.`
|
|
55
|
+
);
|
|
56
|
+
}
|
package/package.json
CHANGED