@ricardo.m.lu/mcphub 0.1.0

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/install.js ADDED
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env node
2
+ // Downloads the mcphub binary for the current platform during npm install
3
+
4
+ const { execSync } = require("child_process");
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+ const https = require("https");
8
+
9
+ const REPO = "Ricardo-M-L/mcphub";
10
+ const VERSION = "v0.1.0";
11
+
12
+ function getPlatform() {
13
+ const os = process.platform;
14
+ const arch = process.arch;
15
+
16
+ const osMap = { darwin: "darwin", linux: "linux", win32: "windows" };
17
+ const archMap = { x64: "amd64", arm64: "arm64" };
18
+
19
+ const mappedOS = osMap[os];
20
+ const mappedArch = archMap[arch];
21
+
22
+ if (!mappedOS || !mappedArch) {
23
+ console.error(`Unsupported platform: ${os}/${arch}`);
24
+ process.exit(1);
25
+ }
26
+
27
+ const ext = os === "win32" ? ".exe" : "";
28
+ return { os: mappedOS, arch: mappedArch, ext };
29
+ }
30
+
31
+ function download(url, dest) {
32
+ return new Promise((resolve, reject) => {
33
+ const follow = (url) => {
34
+ https.get(url, (res) => {
35
+ if (res.statusCode === 302 || res.statusCode === 301) {
36
+ return follow(res.headers.location);
37
+ }
38
+ if (res.statusCode !== 200) {
39
+ return reject(new Error(`Download failed: ${res.statusCode}`));
40
+ }
41
+ const file = fs.createWriteStream(dest);
42
+ res.pipe(file);
43
+ file.on("finish", () => { file.close(); resolve(); });
44
+ }).on("error", reject);
45
+ };
46
+ follow(url);
47
+ });
48
+ }
49
+
50
+ async function main() {
51
+ const { os, arch, ext } = getPlatform();
52
+ const binary = `mcphub-${os}-${arch}${ext}`;
53
+ const url = `https://github.com/${REPO}/releases/download/${VERSION}/${binary}`;
54
+ const dest = path.join(__dirname, `mcphub${ext}`);
55
+
56
+ console.log(`Downloading mcphub for ${os}/${arch}...`);
57
+
58
+ try {
59
+ await download(url, dest);
60
+ fs.chmodSync(dest, 0o755);
61
+ console.log("mcphub installed successfully!");
62
+ } catch (err) {
63
+ console.error(`Failed to download mcphub: ${err.message}`);
64
+ console.error("You can install manually: go install github.com/Ricardo-M-L/mcphub/cmd/mcphub@latest");
65
+ process.exit(1);
66
+ }
67
+ }
68
+
69
+ main();
package/bin/run.js ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ // Wrapper that runs the mcphub Go binary
3
+
4
+ const { execFileSync } = require("child_process");
5
+ const path = require("path");
6
+ const fs = require("fs");
7
+
8
+ const ext = process.platform === "win32" ? ".exe" : "";
9
+ const binary = path.join(__dirname, `mcphub${ext}`);
10
+
11
+ if (!fs.existsSync(binary)) {
12
+ console.error("mcphub binary not found. Run 'npm install' to download it.");
13
+ process.exit(1);
14
+ }
15
+
16
+ try {
17
+ execFileSync(binary, process.argv.slice(2), { stdio: "inherit" });
18
+ } catch (err) {
19
+ process.exit(err.status || 1);
20
+ }
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@ricardo.m.lu/mcphub",
3
+ "version": "0.1.0",
4
+ "description": "The package manager for Model Context Protocol (MCP) servers",
5
+ "bin": {
6
+ "mcphub": "./bin/run.js"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node ./bin/install.js"
10
+ },
11
+ "keywords": [
12
+ "mcp",
13
+ "model-context-protocol",
14
+ "package-manager",
15
+ "ai",
16
+ "claude",
17
+ "cursor"
18
+ ],
19
+ "author": "Ricardo-M-L",
20
+ "license": "Apache-2.0",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/Ricardo-M-L/mcphub.git"
24
+ },
25
+ "homepage": "https://github.com/Ricardo-M-L/mcphub"
26
+ }