@yawlabs/mcph 0.47.7 → 0.47.8
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/dist/index.js +259 -197
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1435,7 +1435,7 @@ function pathFor(client, scope, os, base) {
|
|
|
1435
1435
|
throw new Error(`Unhandled client: ${client}`);
|
|
1436
1436
|
}
|
|
1437
1437
|
function buildLaunchEntry(opts) {
|
|
1438
|
-
const pkg = opts.pkg ?? "@yawlabs/mcph";
|
|
1438
|
+
const pkg = opts.pkg ?? "@yawlabs/mcph@latest";
|
|
1439
1439
|
const entry = opts.os === "windows" ? { command: "cmd", args: ["/c", "npx", "-y", pkg] } : { command: "npx", args: ["-y", pkg] };
|
|
1440
1440
|
if (opts.token) entry.env = { MCPH_TOKEN: opts.token };
|
|
1441
1441
|
return entry;
|
|
@@ -1650,7 +1650,7 @@ function selectFlakyNamespaces(entries, limit) {
|
|
|
1650
1650
|
}
|
|
1651
1651
|
|
|
1652
1652
|
// src/doctor-cmd.ts
|
|
1653
|
-
var VERSION = true ? "0.47.
|
|
1653
|
+
var VERSION = true ? "0.47.8" : "dev";
|
|
1654
1654
|
async function runDoctor(opts = {}) {
|
|
1655
1655
|
if (opts.json) return runDoctorJson(opts);
|
|
1656
1656
|
const lines = [];
|
|
@@ -2905,6 +2905,253 @@ import {
|
|
|
2905
2905
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
2906
2906
|
import { request as request9 } from "undici";
|
|
2907
2907
|
|
|
2908
|
+
// src/auto-upgrade.ts
|
|
2909
|
+
import { spawn as spawn3 } from "child_process";
|
|
2910
|
+
|
|
2911
|
+
// src/upgrade-cmd.ts
|
|
2912
|
+
import { spawn as spawn2 } from "child_process";
|
|
2913
|
+
var UPGRADE_USAGE = `Usage: mcph upgrade [--run] [--json]
|
|
2914
|
+
|
|
2915
|
+
Show (or execute) the command to upgrade @yawlabs/mcph to the latest version.
|
|
2916
|
+
|
|
2917
|
+
--run If this install is global (npm install -g), spawn the upgrade
|
|
2918
|
+
command. No-op for npx installs \u2014 they always fetch the latest.
|
|
2919
|
+
--json Emit a machine-readable snapshot ({ current, latest, stale,
|
|
2920
|
+
method, command }) instead of prose.`;
|
|
2921
|
+
function parseUpgradeArgs(argv) {
|
|
2922
|
+
const opts = {};
|
|
2923
|
+
for (const a of argv) {
|
|
2924
|
+
if (a === "--run") opts.run = true;
|
|
2925
|
+
else if (a === "--json") opts.json = true;
|
|
2926
|
+
else if (a === "--help" || a === "-h") return { ok: false, error: UPGRADE_USAGE };
|
|
2927
|
+
else return { ok: false, error: `mcph upgrade: unknown argument "${a}"
|
|
2928
|
+
|
|
2929
|
+
${UPGRADE_USAGE}` };
|
|
2930
|
+
}
|
|
2931
|
+
return { ok: true, options: opts };
|
|
2932
|
+
}
|
|
2933
|
+
function detectInstallMethod(argvPath) {
|
|
2934
|
+
if (!argvPath) return "unknown";
|
|
2935
|
+
const normalized = argvPath.replace(/\\/g, "/");
|
|
2936
|
+
if (/\/_npx\//.test(normalized)) return "npx";
|
|
2937
|
+
if (/\/npm\/node_modules\/@yawlabs\/mcph\//.test(normalized)) return "global-npm";
|
|
2938
|
+
if (/\/lib\/node_modules\/@yawlabs\/mcph\//.test(normalized)) return "global-npm";
|
|
2939
|
+
if (/\/AppData\/Roaming\/npm\/node_modules\/@yawlabs\/mcph\//.test(normalized)) return "global-npm";
|
|
2940
|
+
if (/\/node_modules\/@yawlabs\/mcph\//.test(normalized)) return "local-node-modules";
|
|
2941
|
+
if (/\/mcph\/(dist|src)\//.test(normalized)) return "dev-checkout";
|
|
2942
|
+
return "unknown";
|
|
2943
|
+
}
|
|
2944
|
+
function buildUpgradePlan(input) {
|
|
2945
|
+
const { current, latest, method } = input;
|
|
2946
|
+
const stale = latest !== null && current !== "dev" && compareSemverLocal(current, latest) < 0;
|
|
2947
|
+
let command;
|
|
2948
|
+
switch (method) {
|
|
2949
|
+
case "global-npm":
|
|
2950
|
+
command = "npm install -g @yawlabs/mcph@latest";
|
|
2951
|
+
break;
|
|
2952
|
+
case "npx":
|
|
2953
|
+
command = null;
|
|
2954
|
+
break;
|
|
2955
|
+
case "local-node-modules":
|
|
2956
|
+
command = "npm install @yawlabs/mcph@latest";
|
|
2957
|
+
break;
|
|
2958
|
+
case "dev-checkout":
|
|
2959
|
+
command = "git pull && npm run build";
|
|
2960
|
+
break;
|
|
2961
|
+
default:
|
|
2962
|
+
command = "npm install -g @yawlabs/mcph@latest";
|
|
2963
|
+
break;
|
|
2964
|
+
}
|
|
2965
|
+
return { current, latest, stale, method, command };
|
|
2966
|
+
}
|
|
2967
|
+
function compareSemverLocal(a, b) {
|
|
2968
|
+
const parse = (s) => {
|
|
2969
|
+
const m = /^v?(\d+)\.(\d+)\.(\d+)/.exec(s);
|
|
2970
|
+
if (!m) return null;
|
|
2971
|
+
return [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
2972
|
+
};
|
|
2973
|
+
const pa = parse(a);
|
|
2974
|
+
const pb = parse(b);
|
|
2975
|
+
if (!pa || !pb) return 0;
|
|
2976
|
+
for (let i = 0; i < 3; i++) {
|
|
2977
|
+
if (pa[i] < pb[i]) return -1;
|
|
2978
|
+
if (pa[i] > pb[i]) return 1;
|
|
2979
|
+
}
|
|
2980
|
+
return 0;
|
|
2981
|
+
}
|
|
2982
|
+
async function defaultFetchLatest() {
|
|
2983
|
+
const ac = new AbortController();
|
|
2984
|
+
const timer = setTimeout(() => ac.abort(), 3e3);
|
|
2985
|
+
try {
|
|
2986
|
+
const res = await fetch("https://registry.npmjs.org/@yawlabs/mcph/latest", {
|
|
2987
|
+
signal: ac.signal,
|
|
2988
|
+
headers: { accept: "application/json" }
|
|
2989
|
+
});
|
|
2990
|
+
if (!res.ok) return null;
|
|
2991
|
+
const body = await res.json();
|
|
2992
|
+
return typeof body.version === "string" ? body.version : null;
|
|
2993
|
+
} catch {
|
|
2994
|
+
return null;
|
|
2995
|
+
} finally {
|
|
2996
|
+
clearTimeout(timer);
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
async function defaultSpawn(cmd, args) {
|
|
3000
|
+
return new Promise((resolve4) => {
|
|
3001
|
+
const child = spawn2(cmd, args, { stdio: "inherit", shell: process.platform === "win32" });
|
|
3002
|
+
child.on("close", (code) => resolve4(typeof code === "number" ? code : 1));
|
|
3003
|
+
child.on("error", () => resolve4(1));
|
|
3004
|
+
});
|
|
3005
|
+
}
|
|
3006
|
+
async function runUpgrade(opts = {}) {
|
|
3007
|
+
const write = opts.out ?? ((s) => process.stdout.write(s));
|
|
3008
|
+
const writeErr = opts.err ?? ((s) => process.stderr.write(s));
|
|
3009
|
+
const lines = [];
|
|
3010
|
+
const print = (s = "") => {
|
|
3011
|
+
lines.push(s);
|
|
3012
|
+
write(`${s}
|
|
3013
|
+
`);
|
|
3014
|
+
};
|
|
3015
|
+
const printErr = (s) => {
|
|
3016
|
+
lines.push(s);
|
|
3017
|
+
writeErr(`${s}
|
|
3018
|
+
`);
|
|
3019
|
+
};
|
|
3020
|
+
const fetcher = opts.fetchLatest ?? defaultFetchLatest;
|
|
3021
|
+
const current = opts.currentVersion ?? readCurrentVersion();
|
|
3022
|
+
const argvPath = opts.argvPath ?? process.argv[1];
|
|
3023
|
+
const method = detectInstallMethod(argvPath);
|
|
3024
|
+
let latest;
|
|
3025
|
+
try {
|
|
3026
|
+
latest = await fetcher();
|
|
3027
|
+
} catch {
|
|
3028
|
+
latest = null;
|
|
3029
|
+
}
|
|
3030
|
+
const plan = buildUpgradePlan({ current, latest, method });
|
|
3031
|
+
if (opts.json) {
|
|
3032
|
+
print(JSON.stringify(plan, null, 2));
|
|
3033
|
+
return { exitCode: plan.stale && !opts.run ? 1 : 0, lines };
|
|
3034
|
+
}
|
|
3035
|
+
if (latest === null) {
|
|
3036
|
+
print("mcph upgrade: couldn't reach the npm registry (offline? firewall?).");
|
|
3037
|
+
if (plan.command) {
|
|
3038
|
+
print(`When you're back online, run:
|
|
3039
|
+
${plan.command}`);
|
|
3040
|
+
} else {
|
|
3041
|
+
print("Your install uses `npx -y` \u2014 just restart the MCP client when you're back online.");
|
|
3042
|
+
}
|
|
3043
|
+
return { exitCode: 0, lines };
|
|
3044
|
+
}
|
|
3045
|
+
print(`Current: ${current}`);
|
|
3046
|
+
print(`Latest: ${latest}`);
|
|
3047
|
+
print(`Install: ${method}`);
|
|
3048
|
+
if (!plan.stale) {
|
|
3049
|
+
print("");
|
|
3050
|
+
print("\u2713 You're on the latest version \u2014 nothing to do.");
|
|
3051
|
+
return { exitCode: 0, lines };
|
|
3052
|
+
}
|
|
3053
|
+
print("");
|
|
3054
|
+
if (method === "npx") {
|
|
3055
|
+
print("Your install uses `npx -y` \u2014 restart the MCP client and it will fetch the new version.");
|
|
3056
|
+
return { exitCode: 0, lines };
|
|
3057
|
+
}
|
|
3058
|
+
if (!plan.command) {
|
|
3059
|
+
print("No upgrade command available for this install method.");
|
|
3060
|
+
return { exitCode: 0, lines };
|
|
3061
|
+
}
|
|
3062
|
+
const autoRunnable = method === "global-npm";
|
|
3063
|
+
if (!opts.run) {
|
|
3064
|
+
if (autoRunnable) {
|
|
3065
|
+
print(`Run:
|
|
3066
|
+
${plan.command}
|
|
3067
|
+
|
|
3068
|
+
Or re-run with --run to upgrade in place.`);
|
|
3069
|
+
} else {
|
|
3070
|
+
print(`Suggested command (run it yourself; --run only works for global-npm installs):
|
|
3071
|
+
${plan.command}`);
|
|
3072
|
+
}
|
|
3073
|
+
return { exitCode: 1, lines };
|
|
3074
|
+
}
|
|
3075
|
+
if (!autoRunnable) {
|
|
3076
|
+
printErr(
|
|
3077
|
+
`mcph upgrade --run: install method "${method}" can't be upgraded automatically. Run manually:
|
|
3078
|
+
${plan.command}`
|
|
3079
|
+
);
|
|
3080
|
+
return { exitCode: 2, lines };
|
|
3081
|
+
}
|
|
3082
|
+
const runner = opts.spawnImpl ?? defaultSpawn;
|
|
3083
|
+
print(`Running: ${plan.command}`);
|
|
3084
|
+
const code = await runner("npm", ["install", "-g", "@yawlabs/mcph@latest"]);
|
|
3085
|
+
if (code === 0) {
|
|
3086
|
+
print("");
|
|
3087
|
+
print(`\u2713 Upgraded @yawlabs/mcph to ${latest}.`);
|
|
3088
|
+
return { exitCode: 0, lines };
|
|
3089
|
+
}
|
|
3090
|
+
printErr(`mcph upgrade: npm exited ${code}. Try running the command manually.`);
|
|
3091
|
+
return { exitCode: 3, lines };
|
|
3092
|
+
}
|
|
3093
|
+
function readCurrentVersion() {
|
|
3094
|
+
return true ? "0.47.8" : "dev";
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
// src/auto-upgrade.ts
|
|
3098
|
+
async function fetchLatestVersion2() {
|
|
3099
|
+
const ac = new AbortController();
|
|
3100
|
+
const timer = setTimeout(() => ac.abort(), 3e3);
|
|
3101
|
+
try {
|
|
3102
|
+
const res = await fetch("https://registry.npmjs.org/@yawlabs/mcph/latest", {
|
|
3103
|
+
signal: ac.signal,
|
|
3104
|
+
headers: { accept: "application/json" }
|
|
3105
|
+
});
|
|
3106
|
+
if (!res.ok) return null;
|
|
3107
|
+
const body = await res.json();
|
|
3108
|
+
return typeof body.version === "string" ? body.version : null;
|
|
3109
|
+
} catch {
|
|
3110
|
+
return null;
|
|
3111
|
+
} finally {
|
|
3112
|
+
clearTimeout(timer);
|
|
3113
|
+
}
|
|
3114
|
+
}
|
|
3115
|
+
function defaultSpawn2(cmd, args) {
|
|
3116
|
+
const child = spawn3(cmd, args, {
|
|
3117
|
+
stdio: "ignore",
|
|
3118
|
+
// Stay a child of this process (not detached) so it dies with mcph
|
|
3119
|
+
// if mcph exits mid-install -- a half-finished `npm i -g` is fine
|
|
3120
|
+
// (npm is atomic per package) and a re-run next startup completes it.
|
|
3121
|
+
detached: false,
|
|
3122
|
+
shell: process.platform === "win32"
|
|
3123
|
+
});
|
|
3124
|
+
child.on("close", (code) => {
|
|
3125
|
+
if (code === 0) {
|
|
3126
|
+
log("info", "mcph self-upgrade complete; the next client restart will run the new version");
|
|
3127
|
+
} else {
|
|
3128
|
+
log("warn", "mcph self-upgrade: npm exited non-zero", { code });
|
|
3129
|
+
}
|
|
3130
|
+
});
|
|
3131
|
+
child.on("error", (err) => {
|
|
3132
|
+
log("warn", "mcph self-upgrade: npm spawn failed", { error: err?.message });
|
|
3133
|
+
});
|
|
3134
|
+
}
|
|
3135
|
+
async function maybeAutoUpgrade(deps = {}) {
|
|
3136
|
+
const current = deps.currentVersion ?? (true ? "0.47.8" : "dev");
|
|
3137
|
+
if (current === "dev") return;
|
|
3138
|
+
const method = detectInstallMethod(deps.argvPath ?? process.argv[1]);
|
|
3139
|
+
const latest = await (deps.fetchLatestImpl ?? fetchLatestVersion2)();
|
|
3140
|
+
if (latest === null) return;
|
|
3141
|
+
const plan = buildUpgradePlan({ current, latest, method });
|
|
3142
|
+
if (!plan.stale) return;
|
|
3143
|
+
if (method === "global-npm") {
|
|
3144
|
+
log("info", "mcph is out of date; upgrading the global install in the background", { current, latest });
|
|
3145
|
+
(deps.spawnImpl ?? defaultSpawn2)("npm", ["install", "-g", "@yawlabs/mcph@latest"]);
|
|
3146
|
+
return;
|
|
3147
|
+
}
|
|
3148
|
+
log("info", "mcph is out of date; restart your MCP client to pick up the latest version", {
|
|
3149
|
+
current,
|
|
3150
|
+
latest,
|
|
3151
|
+
method
|
|
3152
|
+
});
|
|
3153
|
+
}
|
|
3154
|
+
|
|
2908
3155
|
// src/compliance.ts
|
|
2909
3156
|
var GRADE_ORDER = {
|
|
2910
3157
|
A: 4,
|
|
@@ -4500,7 +4747,7 @@ async function rerank(intent, candidateIds, limit) {
|
|
|
4500
4747
|
}
|
|
4501
4748
|
|
|
4502
4749
|
// src/runtime-detect.ts
|
|
4503
|
-
import { spawn as
|
|
4750
|
+
import { spawn as spawn4 } from "child_process";
|
|
4504
4751
|
import { request as request7 } from "undici";
|
|
4505
4752
|
var PROBE_TIMEOUT_MS = 3e3;
|
|
4506
4753
|
var RUNTIME_REPORT_PATH = "/api/connect/runtimes";
|
|
@@ -4558,7 +4805,7 @@ async function probe(name, p) {
|
|
|
4558
4805
|
let stderr = "";
|
|
4559
4806
|
let child;
|
|
4560
4807
|
try {
|
|
4561
|
-
child =
|
|
4808
|
+
child = spawn4(p.bin, p.args, {
|
|
4562
4809
|
stdio: ["ignore", "pipe", "pipe"],
|
|
4563
4810
|
// Windows needs a shell for PATH lookup of .cmd/.bat shims —
|
|
4564
4811
|
// node/npx/uvx arrive as `npx.cmd` in PATH, and native spawn
|
|
@@ -4783,7 +5030,7 @@ import {
|
|
|
4783
5030
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
4784
5031
|
|
|
4785
5032
|
// src/uv-bootstrap.ts
|
|
4786
|
-
import { spawn as
|
|
5033
|
+
import { spawn as spawn5 } from "child_process";
|
|
4787
5034
|
import { createHash } from "crypto";
|
|
4788
5035
|
import { createWriteStream } from "fs";
|
|
4789
5036
|
import fs from "fs/promises";
|
|
@@ -4836,7 +5083,7 @@ async function onPath(cmd) {
|
|
|
4836
5083
|
};
|
|
4837
5084
|
let child;
|
|
4838
5085
|
try {
|
|
4839
|
-
child =
|
|
5086
|
+
child = spawn5(cmd, ["--version"], {
|
|
4840
5087
|
stdio: "ignore",
|
|
4841
5088
|
shell: false,
|
|
4842
5089
|
windowsHide: process.platform === "win32"
|
|
@@ -4897,7 +5144,7 @@ async function extractArchive(archivePath, destDir) {
|
|
|
4897
5144
|
}
|
|
4898
5145
|
function runCommand(cmd, args) {
|
|
4899
5146
|
return new Promise((resolve4, reject) => {
|
|
4900
|
-
const child =
|
|
5147
|
+
const child = spawn5(cmd, args, {
|
|
4901
5148
|
stdio: ["ignore", "pipe", "pipe"],
|
|
4902
5149
|
shell: false,
|
|
4903
5150
|
windowsHide: process.platform === "win32"
|
|
@@ -5015,7 +5262,7 @@ function categorizeSpawnError(err) {
|
|
|
5015
5262
|
}
|
|
5016
5263
|
async function connectToUpstream(config, onDisconnect, onListChanged) {
|
|
5017
5264
|
const client = new Client(
|
|
5018
|
-
{ name: "mcph", version: true ? "0.47.
|
|
5265
|
+
{ name: "mcph", version: true ? "0.47.8" : "dev" },
|
|
5019
5266
|
{ capabilities: {} }
|
|
5020
5267
|
);
|
|
5021
5268
|
let transport;
|
|
@@ -5323,7 +5570,7 @@ var ConnectServer = class _ConnectServer {
|
|
|
5323
5570
|
this.apiUrl = apiUrl6;
|
|
5324
5571
|
this.token = token6;
|
|
5325
5572
|
this.server = new Server(
|
|
5326
|
-
{ name: "mcph", version: true ? "0.47.
|
|
5573
|
+
{ name: "mcph", version: true ? "0.47.8" : "dev" },
|
|
5327
5574
|
{
|
|
5328
5575
|
capabilities: {
|
|
5329
5576
|
tools: { listChanged: true },
|
|
@@ -5609,6 +5856,7 @@ var ConnectServer = class _ConnectServer {
|
|
|
5609
5856
|
await this.server.connect(transport);
|
|
5610
5857
|
this.startPolling();
|
|
5611
5858
|
this.prewarmDormantServers().catch((err) => log("warn", "Pre-warm failed", { error: err?.message }));
|
|
5859
|
+
maybeAutoUpgrade().catch((err) => log("warn", "Auto-upgrade check failed", { error: err?.message }));
|
|
5612
5860
|
if (isAutoLoadEnabled() && this.persistenceReady) {
|
|
5613
5861
|
this.autoLoadRecurringPack().catch((err) => log("warn", "Auto-load failed", { error: err?.message }));
|
|
5614
5862
|
}
|
|
@@ -7522,192 +7770,6 @@ function truncateVersion(v) {
|
|
|
7522
7770
|
return v.length > 8 ? v.slice(0, 8) : v;
|
|
7523
7771
|
}
|
|
7524
7772
|
|
|
7525
|
-
// src/upgrade-cmd.ts
|
|
7526
|
-
import { spawn as spawn4 } from "child_process";
|
|
7527
|
-
var UPGRADE_USAGE = `Usage: mcph upgrade [--run] [--json]
|
|
7528
|
-
|
|
7529
|
-
Show (or execute) the command to upgrade @yawlabs/mcph to the latest version.
|
|
7530
|
-
|
|
7531
|
-
--run If this install is global (npm install -g), spawn the upgrade
|
|
7532
|
-
command. No-op for npx installs \u2014 they always fetch the latest.
|
|
7533
|
-
--json Emit a machine-readable snapshot ({ current, latest, stale,
|
|
7534
|
-
method, command }) instead of prose.`;
|
|
7535
|
-
function parseUpgradeArgs(argv) {
|
|
7536
|
-
const opts = {};
|
|
7537
|
-
for (const a of argv) {
|
|
7538
|
-
if (a === "--run") opts.run = true;
|
|
7539
|
-
else if (a === "--json") opts.json = true;
|
|
7540
|
-
else if (a === "--help" || a === "-h") return { ok: false, error: UPGRADE_USAGE };
|
|
7541
|
-
else return { ok: false, error: `mcph upgrade: unknown argument "${a}"
|
|
7542
|
-
|
|
7543
|
-
${UPGRADE_USAGE}` };
|
|
7544
|
-
}
|
|
7545
|
-
return { ok: true, options: opts };
|
|
7546
|
-
}
|
|
7547
|
-
function detectInstallMethod(argvPath) {
|
|
7548
|
-
if (!argvPath) return "unknown";
|
|
7549
|
-
const normalized = argvPath.replace(/\\/g, "/");
|
|
7550
|
-
if (/\/_npx\//.test(normalized)) return "npx";
|
|
7551
|
-
if (/\/npm\/node_modules\/@yawlabs\/mcph\//.test(normalized)) return "global-npm";
|
|
7552
|
-
if (/\/lib\/node_modules\/@yawlabs\/mcph\//.test(normalized)) return "global-npm";
|
|
7553
|
-
if (/\/AppData\/Roaming\/npm\/node_modules\/@yawlabs\/mcph\//.test(normalized)) return "global-npm";
|
|
7554
|
-
if (/\/node_modules\/@yawlabs\/mcph\//.test(normalized)) return "local-node-modules";
|
|
7555
|
-
if (/\/mcph\/(dist|src)\//.test(normalized)) return "dev-checkout";
|
|
7556
|
-
return "unknown";
|
|
7557
|
-
}
|
|
7558
|
-
function buildUpgradePlan(input) {
|
|
7559
|
-
const { current, latest, method } = input;
|
|
7560
|
-
const stale = latest !== null && current !== "dev" && compareSemverLocal(current, latest) < 0;
|
|
7561
|
-
let command;
|
|
7562
|
-
switch (method) {
|
|
7563
|
-
case "global-npm":
|
|
7564
|
-
command = "npm install -g @yawlabs/mcph@latest";
|
|
7565
|
-
break;
|
|
7566
|
-
case "npx":
|
|
7567
|
-
command = null;
|
|
7568
|
-
break;
|
|
7569
|
-
case "local-node-modules":
|
|
7570
|
-
command = "npm install @yawlabs/mcph@latest";
|
|
7571
|
-
break;
|
|
7572
|
-
case "dev-checkout":
|
|
7573
|
-
command = "git pull && npm run build";
|
|
7574
|
-
break;
|
|
7575
|
-
default:
|
|
7576
|
-
command = "npm install -g @yawlabs/mcph@latest";
|
|
7577
|
-
break;
|
|
7578
|
-
}
|
|
7579
|
-
return { current, latest, stale, method, command };
|
|
7580
|
-
}
|
|
7581
|
-
function compareSemverLocal(a, b) {
|
|
7582
|
-
const parse = (s) => {
|
|
7583
|
-
const m = /^v?(\d+)\.(\d+)\.(\d+)/.exec(s);
|
|
7584
|
-
if (!m) return null;
|
|
7585
|
-
return [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
7586
|
-
};
|
|
7587
|
-
const pa = parse(a);
|
|
7588
|
-
const pb = parse(b);
|
|
7589
|
-
if (!pa || !pb) return 0;
|
|
7590
|
-
for (let i = 0; i < 3; i++) {
|
|
7591
|
-
if (pa[i] < pb[i]) return -1;
|
|
7592
|
-
if (pa[i] > pb[i]) return 1;
|
|
7593
|
-
}
|
|
7594
|
-
return 0;
|
|
7595
|
-
}
|
|
7596
|
-
async function defaultFetchLatest() {
|
|
7597
|
-
const ac = new AbortController();
|
|
7598
|
-
const timer = setTimeout(() => ac.abort(), 3e3);
|
|
7599
|
-
try {
|
|
7600
|
-
const res = await fetch("https://registry.npmjs.org/@yawlabs/mcph/latest", {
|
|
7601
|
-
signal: ac.signal,
|
|
7602
|
-
headers: { accept: "application/json" }
|
|
7603
|
-
});
|
|
7604
|
-
if (!res.ok) return null;
|
|
7605
|
-
const body = await res.json();
|
|
7606
|
-
return typeof body.version === "string" ? body.version : null;
|
|
7607
|
-
} catch {
|
|
7608
|
-
return null;
|
|
7609
|
-
} finally {
|
|
7610
|
-
clearTimeout(timer);
|
|
7611
|
-
}
|
|
7612
|
-
}
|
|
7613
|
-
async function defaultSpawn(cmd, args) {
|
|
7614
|
-
return new Promise((resolve4) => {
|
|
7615
|
-
const child = spawn4(cmd, args, { stdio: "inherit", shell: process.platform === "win32" });
|
|
7616
|
-
child.on("close", (code) => resolve4(typeof code === "number" ? code : 1));
|
|
7617
|
-
child.on("error", () => resolve4(1));
|
|
7618
|
-
});
|
|
7619
|
-
}
|
|
7620
|
-
async function runUpgrade(opts = {}) {
|
|
7621
|
-
const write = opts.out ?? ((s) => process.stdout.write(s));
|
|
7622
|
-
const writeErr = opts.err ?? ((s) => process.stderr.write(s));
|
|
7623
|
-
const lines = [];
|
|
7624
|
-
const print = (s = "") => {
|
|
7625
|
-
lines.push(s);
|
|
7626
|
-
write(`${s}
|
|
7627
|
-
`);
|
|
7628
|
-
};
|
|
7629
|
-
const printErr = (s) => {
|
|
7630
|
-
lines.push(s);
|
|
7631
|
-
writeErr(`${s}
|
|
7632
|
-
`);
|
|
7633
|
-
};
|
|
7634
|
-
const fetcher = opts.fetchLatest ?? defaultFetchLatest;
|
|
7635
|
-
const current = opts.currentVersion ?? readCurrentVersion();
|
|
7636
|
-
const argvPath = opts.argvPath ?? process.argv[1];
|
|
7637
|
-
const method = detectInstallMethod(argvPath);
|
|
7638
|
-
let latest;
|
|
7639
|
-
try {
|
|
7640
|
-
latest = await fetcher();
|
|
7641
|
-
} catch {
|
|
7642
|
-
latest = null;
|
|
7643
|
-
}
|
|
7644
|
-
const plan = buildUpgradePlan({ current, latest, method });
|
|
7645
|
-
if (opts.json) {
|
|
7646
|
-
print(JSON.stringify(plan, null, 2));
|
|
7647
|
-
return { exitCode: plan.stale && !opts.run ? 1 : 0, lines };
|
|
7648
|
-
}
|
|
7649
|
-
if (latest === null) {
|
|
7650
|
-
print("mcph upgrade: couldn't reach the npm registry (offline? firewall?).");
|
|
7651
|
-
if (plan.command) {
|
|
7652
|
-
print(`When you're back online, run:
|
|
7653
|
-
${plan.command}`);
|
|
7654
|
-
} else {
|
|
7655
|
-
print("Your install uses `npx -y` \u2014 just restart the MCP client when you're back online.");
|
|
7656
|
-
}
|
|
7657
|
-
return { exitCode: 0, lines };
|
|
7658
|
-
}
|
|
7659
|
-
print(`Current: ${current}`);
|
|
7660
|
-
print(`Latest: ${latest}`);
|
|
7661
|
-
print(`Install: ${method}`);
|
|
7662
|
-
if (!plan.stale) {
|
|
7663
|
-
print("");
|
|
7664
|
-
print("\u2713 You're on the latest version \u2014 nothing to do.");
|
|
7665
|
-
return { exitCode: 0, lines };
|
|
7666
|
-
}
|
|
7667
|
-
print("");
|
|
7668
|
-
if (method === "npx") {
|
|
7669
|
-
print("Your install uses `npx -y` \u2014 restart the MCP client and it will fetch the new version.");
|
|
7670
|
-
return { exitCode: 0, lines };
|
|
7671
|
-
}
|
|
7672
|
-
if (!plan.command) {
|
|
7673
|
-
print("No upgrade command available for this install method.");
|
|
7674
|
-
return { exitCode: 0, lines };
|
|
7675
|
-
}
|
|
7676
|
-
const autoRunnable = method === "global-npm";
|
|
7677
|
-
if (!opts.run) {
|
|
7678
|
-
if (autoRunnable) {
|
|
7679
|
-
print(`Run:
|
|
7680
|
-
${plan.command}
|
|
7681
|
-
|
|
7682
|
-
Or re-run with --run to upgrade in place.`);
|
|
7683
|
-
} else {
|
|
7684
|
-
print(`Suggested command (run it yourself; --run only works for global-npm installs):
|
|
7685
|
-
${plan.command}`);
|
|
7686
|
-
}
|
|
7687
|
-
return { exitCode: 1, lines };
|
|
7688
|
-
}
|
|
7689
|
-
if (!autoRunnable) {
|
|
7690
|
-
printErr(
|
|
7691
|
-
`mcph upgrade --run: install method "${method}" can't be upgraded automatically. Run manually:
|
|
7692
|
-
${plan.command}`
|
|
7693
|
-
);
|
|
7694
|
-
return { exitCode: 2, lines };
|
|
7695
|
-
}
|
|
7696
|
-
const runner = opts.spawnImpl ?? defaultSpawn;
|
|
7697
|
-
print(`Running: ${plan.command}`);
|
|
7698
|
-
const code = await runner("npm", ["install", "-g", "@yawlabs/mcph@latest"]);
|
|
7699
|
-
if (code === 0) {
|
|
7700
|
-
print("");
|
|
7701
|
-
print(`\u2713 Upgraded @yawlabs/mcph to ${latest}.`);
|
|
7702
|
-
return { exitCode: 0, lines };
|
|
7703
|
-
}
|
|
7704
|
-
printErr(`mcph upgrade: npm exited ${code}. Try running the command manually.`);
|
|
7705
|
-
return { exitCode: 3, lines };
|
|
7706
|
-
}
|
|
7707
|
-
function readCurrentVersion() {
|
|
7708
|
-
return true ? "0.47.7" : "dev";
|
|
7709
|
-
}
|
|
7710
|
-
|
|
7711
7773
|
// src/index.ts
|
|
7712
7774
|
var KNOWN_SUBCOMMANDS = [
|
|
7713
7775
|
"compliance",
|
|
@@ -7873,7 +7935,7 @@ if (subcommand === "compliance") {
|
|
|
7873
7935
|
`);
|
|
7874
7936
|
process.exit(0);
|
|
7875
7937
|
} else if (subcommand === "--version" || subcommand === "-V") {
|
|
7876
|
-
process.stdout.write(`mcph ${true ? "0.47.
|
|
7938
|
+
process.stdout.write(`mcph ${true ? "0.47.8" : "dev"}
|
|
7877
7939
|
`);
|
|
7878
7940
|
process.exit(0);
|
|
7879
7941
|
} else if (subcommand && !subcommand.startsWith("-")) {
|
|
@@ -7890,7 +7952,7 @@ async function runServer() {
|
|
|
7890
7952
|
const config = await loadMcphConfig();
|
|
7891
7953
|
if (!config.token) {
|
|
7892
7954
|
process.stderr.write(
|
|
7893
|
-
'\n mcph: no token resolved.\n\n Quick start (recommended):\n mcph install <claude-code|claude-desktop|cursor|vscode> --token mcp_pat_\u2026\n Creates ~/.mcph/config.json so every MCP client picks up the token automatically.\n\n Or set MCPH_TOKEN in your MCP client config:\n\n {\n "mcpServers": {\n "mcp.hosting": {\n "command": "npx",\n "args": ["-y", "@yawlabs/mcph"],\n "env": {\n "MCPH_TOKEN": "mcp_pat_your_token_here"\n }\n }\n }\n }\n\n Get a token at https://mcp.hosting \u2192 Settings \u2192 API Tokens, or run\n `mcph doctor` to see exactly where mcph looked.\n\n'
|
|
7955
|
+
'\n mcph: no token resolved.\n\n Quick start (recommended):\n mcph install <claude-code|claude-desktop|cursor|vscode> --token mcp_pat_\u2026\n Creates ~/.mcph/config.json so every MCP client picks up the token automatically.\n\n Or set MCPH_TOKEN in your MCP client config:\n\n {\n "mcpServers": {\n "mcp.hosting": {\n "command": "npx",\n "args": ["-y", "@yawlabs/mcph@latest"],\n "env": {\n "MCPH_TOKEN": "mcp_pat_your_token_here"\n }\n }\n }\n }\n\n Get a token at https://mcp.hosting \u2192 Settings \u2192 API Tokens, or run\n `mcph doctor` to see exactly where mcph looked.\n\n'
|
|
7894
7956
|
);
|
|
7895
7957
|
process.exit(1);
|
|
7896
7958
|
}
|
package/package.json
CHANGED