@cookmd/nutrition-mcp 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.
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ const path = require("path");
3
+ const { spawn } = require("child_process");
4
+ const bin = path.join(__dirname, "..", "dist", "nutrition-mcp");
5
+ const child = spawn(bin, process.argv.slice(2), { stdio: "inherit" });
6
+ child.on("exit", (code, signal) => process.exit(signal ? 1 : code ?? 1));
7
+ child.on("error", (e) => {
8
+ console.error(
9
+ `nutrition-mcp binary missing or not executable (${e.message}). Reinstall the package.`
10
+ );
11
+ process.exit(1);
12
+ });
package/checksums.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "aarch64-apple-darwin": "f138df347eaa8ee3222e69481aac26e2c4fc6dd8dc28f0dc8809bd6e3ddf3272",
3
+ "aarch64-unknown-linux-gnu": "7b4f6290bc544022839c1a835c45b224c4e44c0d5518f24e5c165814c02565ee",
4
+ "x86_64-apple-darwin": "e26cc4b366d22067e7750684a133ae9ed33b1d442ceff2577b046e7639f73a84",
5
+ "x86_64-unknown-linux-gnu": "f81675a01ecf4375ad468a9c05551f2e87597162f94169931d741a38c334257c"
6
+ }
package/install.js ADDED
@@ -0,0 +1,58 @@
1
+ // Downloads the prebuilt nutrition-mcp binary for this platform from the
2
+ // public releases repo. No compilation on the client.
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const crypto = require("crypto");
6
+ const { Readable } = require("stream");
7
+ const { pipeline } = require("stream/promises");
8
+
9
+ const TARGETS = {
10
+ "darwin-arm64": "aarch64-apple-darwin",
11
+ "darwin-x64": "x86_64-apple-darwin",
12
+ "linux-x64": "x86_64-unknown-linux-gnu",
13
+ "linux-arm64": "aarch64-unknown-linux-gnu",
14
+ };
15
+
16
+ // NUTRITION_MCP_DOWNLOAD_BASE lets internal mirrors override where binaries
17
+ // are fetched from; layout must match the GitHub releases URL scheme.
18
+ const BASE =
19
+ process.env.NUTRITION_MCP_DOWNLOAD_BASE ||
20
+ "https://github.com/cook-md/nutrition-mcp/releases/download";
21
+
22
+ async function main() {
23
+ const key = `${process.platform}-${process.arch}`;
24
+ const target = TARGETS[key];
25
+ if (!target) {
26
+ throw new Error(
27
+ `unsupported platform: ${key} (supported: ${Object.keys(TARGETS).join(", ")})`
28
+ );
29
+ }
30
+ const version = require("./package.json").version;
31
+ // Written by the release workflow at publish time: {target: sha256}.
32
+ const expected = require("./checksums.json")[target];
33
+ if (!expected) throw new Error(`no checksum recorded for ${target}`);
34
+ const url = `${BASE}/v${version}/nutrition-mcp-${target}.tar.gz`;
35
+ const destDir = path.join(__dirname, "dist");
36
+ fs.mkdirSync(destDir, { recursive: true });
37
+ const res = await fetch(url, { redirect: "follow" });
38
+ if (!res.ok) throw new Error(`download failed ${res.status}: ${url}`);
39
+ const tarPath = path.join(destDir, "bin.tar.gz");
40
+ await pipeline(Readable.fromWeb(res.body), fs.createWriteStream(tarPath));
41
+ const actual = crypto
42
+ .createHash("sha256")
43
+ .update(fs.readFileSync(tarPath))
44
+ .digest("hex");
45
+ if (actual !== expected) {
46
+ fs.rmSync(tarPath);
47
+ throw new Error("checksum mismatch — refusing to install");
48
+ }
49
+ const { execFileSync } = require("child_process");
50
+ execFileSync("tar", ["-xzf", tarPath, "-C", destDir]);
51
+ fs.rmSync(tarPath);
52
+ fs.chmodSync(path.join(destDir, "nutrition-mcp"), 0o755);
53
+ }
54
+
55
+ main().catch((e) => {
56
+ console.error(e.message);
57
+ process.exit(1);
58
+ });
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@cookmd/nutrition-mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP server for cook.md nutrition evaluation and cooklang report rendering",
5
+ "bin": {
6
+ "nutrition-mcp": "bin/nutrition-mcp.js"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node install.js"
10
+ },
11
+ "files": [
12
+ "bin/",
13
+ "install.js",
14
+ "checksums.json"
15
+ ],
16
+ "license": "SEE LICENSE AT https://cook.md",
17
+ "engines": {
18
+ "node": ">=18"
19
+ }
20
+ }