mcp-better 0.4.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/LICENSE +21 -0
- package/README.md +177 -0
- package/bin/mcp-better.js +50 -0
- package/lib/download.js +225 -0
- package/lib/platform.js +37 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Wolfe-Jam
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# mcp-better — built for 7/28
|
|
2
|
+
|
|
3
|
+
**NONE | GOOD | [BETTER] | BEST**
|
|
4
|
+
|
|
5
|
+
*(protocol **2026-07-28** — the modern MCP release)*
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
the book is the app is the book
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
AAIF-verified modern MCP textbook **that runs**. Rust · `rmcp` **3.0.x** (lock **3.0.1**, Tier 1 assessed) · Discover · stamped list cache.
|
|
12
|
+
**Book:** [`textbook/`](./textbook/) — what · why · how · [doctrine](./textbook/DOCTRINE-book-is-app.md).
|
|
13
|
+
**App:** this binary + smokes. Lesson after lesson, version after version — knowledge compounds.
|
|
14
|
+
|
|
15
|
+
> **BEST** (persistent AI project context) lives at **[faf.one/agents](https://faf.one/agents)** — one hop up from this textbook.
|
|
16
|
+
|
|
17
|
+
## What is 7/28?
|
|
18
|
+
|
|
19
|
+
| Name | What it is |
|
|
20
|
+
|------|------------|
|
|
21
|
+
| **7/28** | The **era name** — speakable, brandable. “Built for 7/28.” |
|
|
22
|
+
| **2026-07-28** | The **protocol version** — the date string on the wire / in SDKs. |
|
|
23
|
+
|
|
24
|
+
**7/28 is a great name. 2026-07-28 is a date.**
|
|
25
|
+
Humans say **7/28**. Machines negotiate **`2026-07-28`**.
|
|
26
|
+
|
|
27
|
+
## What to expect
|
|
28
|
+
|
|
29
|
+
1. **Built for 7/28** — not bolted onto a legacy server (official `rmcp` 3.0.x / Tier-1 assessed cut).
|
|
30
|
+
2. **Honest surface** — transport and capabilities match docs and CI.
|
|
31
|
+
3. **Roadmap expands the era** — versions add road; they do not “become” 7/28 later.
|
|
32
|
+
|
|
33
|
+
| Version | Lesson (the version *is* the lesson) |
|
|
34
|
+
|---------|--------------------------------------|
|
|
35
|
+
| **v0.1** | **7/28 over stdio** — Discover, stamped `ttlMs` / `cacheScope`, stable order, `health` + `echo` |
|
|
36
|
+
| **v0.2** | Same 7/28 era + **Streamable HTTP** road + routing headers (`Mcp-Method` / `Mcp-Name`) |
|
|
37
|
+
| **v0.3** | Same era + **deeper correctness** — multi-list + restart-order smokes · `mcp-worse` contrast |
|
|
38
|
+
| **v0.4** | Same era + **dual package** — cargo + npm shim · `npx mcp-better` with **no Rust toolchain** |
|
|
39
|
+
|
|
40
|
+
## What BETTER means
|
|
41
|
+
|
|
42
|
+
1. **Protocol honesty** — claim 7/28 / `2026-07-28` only for surfaces you implement and test.
|
|
43
|
+
2. **Discover-compatible** — clients should use `ClientLifecycleMode::Discover` (or Auto → 7/28), not only legacy initialize.
|
|
44
|
+
3. **List cache stamps** — `tools/list` returns positive `ttlMs` and `cacheScope` (static catalog → `public`). SDK defaults are unstamped.
|
|
45
|
+
4. **Stable tool order** — same process, same order across N list calls.
|
|
46
|
+
5. **Transports** — **stdio** (default) and **Streamable HTTP** (`--http`) in the **same 7/28 era**.
|
|
47
|
+
|
|
48
|
+
## Quickstart (≤10 min)
|
|
49
|
+
|
|
50
|
+
### Zero Rust — npm / npx (v0.4+)
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# No Rust toolchain required. Downloads the native binary from GitHub Releases.
|
|
54
|
+
npx mcp-better --help
|
|
55
|
+
npx mcp-better
|
|
56
|
+
# hosts: point stdio command at `npx` / `mcp-better` from the npm package
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### From source / crates.io (Rust 1.85+)
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
git clone https://github.com/Wolfe-Jam/mcp-better.git
|
|
63
|
+
cd mcp-better
|
|
64
|
+
cargo build --bins
|
|
65
|
+
cargo test
|
|
66
|
+
cargo run --example stdio-client
|
|
67
|
+
# louder 0.3 smokes (build --bins first; or: bash scripts/ci.sh)
|
|
68
|
+
MCP_BETTER_BIN="$(pwd)/target/debug/mcp-better" cargo run --example order-restart-smoke
|
|
69
|
+
MCP_BETTER_BIN="$(pwd)/target/debug/mcp-better" \
|
|
70
|
+
MCP_WORSE_BIN="$(pwd)/target/debug/mcp-worse" \
|
|
71
|
+
cargo run --example contrast-smoke
|
|
72
|
+
MCP_BETTER_BIN="$(pwd)/target/debug/mcp-better" cargo run --example http-smoke
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**stdio** (default — Cursor / Claude Desktop):
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
cargo run --release
|
|
79
|
+
# or from crates.io:
|
|
80
|
+
cargo install mcp-better --version 0.4.0
|
|
81
|
+
mcp-better --help
|
|
82
|
+
# optional lying companion (teaching only — not for hosts):
|
|
83
|
+
# cargo install mcp-better --version 0.4.0 --bin mcp-worse
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
> First cargo install compiles the ecosystem once (not 100+ of our tools — just Rust deps). One-time wait; then you’re done.
|
|
87
|
+
> Prefer **no compile**? Use `npx mcp-better` (npm shim).
|
|
88
|
+
|
|
89
|
+
**Streamable HTTP** (local demo only — see [SECURITY.md](./SECURITY.md)):
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
cargo run --release -- --http
|
|
93
|
+
# http://127.0.0.1:8787/mcp
|
|
94
|
+
# MCP_BETTER_HTTP_ADDR=127.0.0.1:9000 mcp-better --http
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Transport selection** (CLI wins over env):
|
|
98
|
+
|
|
99
|
+
| How | Value |
|
|
100
|
+
|-----|--------|
|
|
101
|
+
| CLI | `mcp-better` (stdio) · `mcp-better --http` · `mcp-better --stdio` |
|
|
102
|
+
| Bare args | `http` / `stdio` (same meaning as flags) |
|
|
103
|
+
| Env | `MCP_TRANSPORT` or `MCP_BETTER_TRANSPORT` → `stdio` \| `http` (**`MCP_TRANSPORT` first** if both set) |
|
|
104
|
+
| HTTP bind | `MCP_BETTER_HTTP_ADDR` — default **`127.0.0.1:8787`**. Do **not** use `0.0.0.0` unless you accept an unauthenticated open endpoint. |
|
|
105
|
+
|
|
106
|
+
## Tools
|
|
107
|
+
|
|
108
|
+
| Tool | Purpose |
|
|
109
|
+
|------|---------|
|
|
110
|
+
| `health` | Liveness — status, version, protocol. No side effects. Not a k8s probe contract. |
|
|
111
|
+
| `echo` | Pure demo — returns `message` unchanged. |
|
|
112
|
+
|
|
113
|
+
## Protocol claims (v0.4 — same 7/28 era, dual package)
|
|
114
|
+
|
|
115
|
+
| Surface | Status |
|
|
116
|
+
|---------|--------|
|
|
117
|
+
| Era / protocol | **7/28** · negotiated **`2026-07-28`** (Discover preferred) |
|
|
118
|
+
| Transport | **stdio** (default) · **Streamable HTTP** (`--http`) |
|
|
119
|
+
| HTTP mode | Stateless for 7/28 · `json_response` · local **Host** guards |
|
|
120
|
+
| Routing headers | Streamable HTTP POSTs use **`Mcp-Method`** and **`Mcp-Name`** when naming a tool (SEP-2243); `http-smoke` asserts this happy path |
|
|
121
|
+
| Capabilities | **tools** only |
|
|
122
|
+
| List cache | **`ttlMs=60000`**, **`cacheScope=public`**, order **`health`→`echo`** (restart-stable) |
|
|
123
|
+
| Lying companion | **`mcp-worse`** — unstamped + reversed order (contrast-smoke only) |
|
|
124
|
+
| Resources / prompts / OAuth / tasks | out of hero |
|
|
125
|
+
|
|
126
|
+
## Textbook
|
|
127
|
+
|
|
128
|
+
The book is the app is the book — [`textbook/`](./textbook/) (Season 1 · [doctrine](./textbook/DOCTRINE-book-is-app.md)).
|
|
129
|
+
|
|
130
|
+
Start: [textbook/README.md](./textbook/README.md) → lab [Ch 09](./textbook/09-run-the-textbook.md).
|
|
131
|
+
|
|
132
|
+
## Non-goals (GOOD-era habits we refuse)
|
|
133
|
+
|
|
134
|
+
- Shipping unstamped list results while claiming 7/28 modernity
|
|
135
|
+
- Requiring `project.faf` or any BEST tooling on this repo’s main branch
|
|
136
|
+
- Treating stdio as “not real 7/28” — **stdio is a first-class 7/28 transport**
|
|
137
|
+
- FAF install tax in the AAIF lede — this repo is protocol textbook, not a FAF product
|
|
138
|
+
|
|
139
|
+
## Registry identity
|
|
140
|
+
|
|
141
|
+
- MCP Registry name: `mcp-name: io.github.Wolfe-Jam/mcp-better`
|
|
142
|
+
- **Dual packages** (same version, both **stdio**):
|
|
143
|
+
- `registryType`: **cargo** · `identifier`: `mcp-better` · crates.io
|
|
144
|
+
- `registryType`: **npm** · `identifier`: `mcp-better` · registry.npmjs.org
|
|
145
|
+
(Node shim downloads the native binary from GitHub Releases — no Rust on the host)
|
|
146
|
+
- **Package transport in `server.json` is stdio only — by design.**
|
|
147
|
+
Hosts spawn via `cargo install` / `npx mcp-better` on **stdio**.
|
|
148
|
+
Streamable HTTP (`--http`) is an **opt-in local demo** in the same binary and the same 7/28 era; it is **not** a Registry remote package. Discover it in this README and `--help`.
|
|
149
|
+
|
|
150
|
+
See [`server.json`](./server.json). **Not** `one.faf/*`.
|
|
151
|
+
|
|
152
|
+
## Publish
|
|
153
|
+
|
|
154
|
+
Ship process: **`/pubbetter`** (skill) · short form [`docs/PUBBETTER.md`](./docs/PUBBETTER.md) · local ship bar:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
export PATH="$HOME/.cargo/bin:$PATH"
|
|
158
|
+
bash scripts/ci.sh
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## BEST
|
|
162
|
+
|
|
163
|
+
For persistent, versionable AI project context beyond a protocol textbook:
|
|
164
|
+
|
|
165
|
+
**https://faf.one/agents**
|
|
166
|
+
|
|
167
|
+
## Docs
|
|
168
|
+
|
|
169
|
+
- [BETTER.md](./BETTER.md) — ladder + claim surface
|
|
170
|
+
- [docs/BETTER-BEST.md](./docs/BETTER-BEST.md) — BETTER vs BEST
|
|
171
|
+
- [GETTING-STARTED.md](./GETTING-STARTED.md)
|
|
172
|
+
- [docs/SDK-NOTES.md](./docs/SDK-NOTES.md) — `serve` vs Discover honesty
|
|
173
|
+
- [SECURITY.md](./SECURITY.md) · [CONTRIBUTING.md](./CONTRIBUTING.md)
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
MIT — see [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* npm shim for mcp-better — zero Rust toolchain required.
|
|
6
|
+
*
|
|
7
|
+
* Detects platform/arch, downloads the matching binary from GitHub Releases
|
|
8
|
+
* (cargo-dist asset layout), then execs it with inherited stdio.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const { spawn } = require("child_process");
|
|
12
|
+
const path = require("path");
|
|
13
|
+
const { ensureBinary } = require("../lib/download");
|
|
14
|
+
|
|
15
|
+
const pkg = require("../package.json");
|
|
16
|
+
const version = pkg.version;
|
|
17
|
+
|
|
18
|
+
async function main() {
|
|
19
|
+
// Escape hatch: use a local/dev binary without download
|
|
20
|
+
const override = process.env.MCP_BETTER_BIN;
|
|
21
|
+
let bin;
|
|
22
|
+
if (override) {
|
|
23
|
+
bin = override;
|
|
24
|
+
} else {
|
|
25
|
+
bin = await ensureBinary(version);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const child = spawn(bin, process.argv.slice(2), {
|
|
29
|
+
stdio: "inherit",
|
|
30
|
+
windowsHide: true,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
child.on("error", (err) => {
|
|
34
|
+
console.error(`mcp-better: failed to spawn ${bin}: ${err.message}`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
child.on("exit", (code, signal) => {
|
|
39
|
+
if (signal) {
|
|
40
|
+
process.kill(process.pid, signal);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
process.exit(code == null ? 1 : code);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
main().catch((err) => {
|
|
48
|
+
console.error(err.message || err);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
});
|
package/lib/download.js
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const https = require("https");
|
|
7
|
+
const http = require("http");
|
|
8
|
+
const { execFileSync } = require("child_process");
|
|
9
|
+
const { resolveTarget } = require("./platform");
|
|
10
|
+
|
|
11
|
+
const OWNER = "Wolfe-Jam";
|
|
12
|
+
const REPO = "mcp-better";
|
|
13
|
+
const APP = "mcp-better";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Cache dir for downloaded binaries (versioned + triple).
|
|
17
|
+
* @param {string} version
|
|
18
|
+
* @param {string} triple
|
|
19
|
+
*/
|
|
20
|
+
function cacheDir(version, triple) {
|
|
21
|
+
const base =
|
|
22
|
+
process.env.MCP_BETTER_CACHE_DIR ||
|
|
23
|
+
path.join(os.homedir(), ".cache", "mcp-better");
|
|
24
|
+
return path.join(base, version, triple);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Follow redirects (GitHub release assets).
|
|
29
|
+
* @param {string} url
|
|
30
|
+
* @param {string} dest
|
|
31
|
+
* @param {number} redirects
|
|
32
|
+
*/
|
|
33
|
+
function downloadFile(url, dest, redirects = 0) {
|
|
34
|
+
if (redirects > 10) {
|
|
35
|
+
throw new Error(`mcp-better: too many redirects fetching ${url}`);
|
|
36
|
+
}
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
const lib = url.startsWith("https:") ? https : http;
|
|
39
|
+
const req = lib.get(
|
|
40
|
+
url,
|
|
41
|
+
{
|
|
42
|
+
headers: {
|
|
43
|
+
"User-Agent": "mcp-better-npm-shim",
|
|
44
|
+
Accept: "application/octet-stream",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
(res) => {
|
|
48
|
+
if (
|
|
49
|
+
res.statusCode &&
|
|
50
|
+
res.statusCode >= 300 &&
|
|
51
|
+
res.statusCode < 400 &&
|
|
52
|
+
res.headers.location
|
|
53
|
+
) {
|
|
54
|
+
res.resume();
|
|
55
|
+
downloadFile(res.headers.location, dest, redirects + 1)
|
|
56
|
+
.then(resolve)
|
|
57
|
+
.catch(reject);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (res.statusCode !== 200) {
|
|
61
|
+
res.resume();
|
|
62
|
+
reject(
|
|
63
|
+
new Error(
|
|
64
|
+
`mcp-better: download failed HTTP ${res.statusCode} for ${url}`
|
|
65
|
+
)
|
|
66
|
+
);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const tmp = `${dest}.partial`;
|
|
70
|
+
const out = fs.createWriteStream(tmp);
|
|
71
|
+
res.pipe(out);
|
|
72
|
+
out.on("finish", () => {
|
|
73
|
+
out.close(() => {
|
|
74
|
+
fs.renameSync(tmp, dest);
|
|
75
|
+
resolve();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
out.on("error", (err) => {
|
|
79
|
+
try {
|
|
80
|
+
fs.unlinkSync(tmp);
|
|
81
|
+
} catch {
|
|
82
|
+
/* ignore */
|
|
83
|
+
}
|
|
84
|
+
reject(err);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
req.on("error", reject);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Extract archive to dir. Prefer system tar; fall back to PowerShell Expand-Archive on Windows zip.
|
|
94
|
+
* @param {string} archivePath
|
|
95
|
+
* @param {string} destDir
|
|
96
|
+
* @param {boolean} isWindows
|
|
97
|
+
*/
|
|
98
|
+
function extractArchive(archivePath, destDir, isWindows) {
|
|
99
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
100
|
+
if (archivePath.endsWith(".zip")) {
|
|
101
|
+
if (isWindows) {
|
|
102
|
+
execFileSync(
|
|
103
|
+
"powershell.exe",
|
|
104
|
+
[
|
|
105
|
+
"-NoProfile",
|
|
106
|
+
"-Command",
|
|
107
|
+
`Expand-Archive -Path '${archivePath.replace(/'/g, "''")}' -DestinationPath '${destDir.replace(/'/g, "''")}' -Force`,
|
|
108
|
+
],
|
|
109
|
+
{ stdio: "inherit" }
|
|
110
|
+
);
|
|
111
|
+
} else {
|
|
112
|
+
execFileSync("unzip", ["-o", archivePath, "-d", destDir], {
|
|
113
|
+
stdio: "inherit",
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
// .tar.gz / .tar.xz
|
|
119
|
+
execFileSync("tar", ["-xf", archivePath, "-C", destDir], {
|
|
120
|
+
stdio: "inherit",
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Find binary under extracted tree (cargo-dist may nest by triple).
|
|
126
|
+
* @param {string} root
|
|
127
|
+
* @param {string} binaryName
|
|
128
|
+
*/
|
|
129
|
+
function findBinary(root, binaryName) {
|
|
130
|
+
const direct = path.join(root, binaryName);
|
|
131
|
+
if (fs.existsSync(direct) && fs.statSync(direct).isFile()) {
|
|
132
|
+
return direct;
|
|
133
|
+
}
|
|
134
|
+
/** @type {string[]} */
|
|
135
|
+
const stack = [root];
|
|
136
|
+
while (stack.length) {
|
|
137
|
+
const dir = stack.pop();
|
|
138
|
+
let entries;
|
|
139
|
+
try {
|
|
140
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
141
|
+
} catch {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
for (const ent of entries) {
|
|
145
|
+
const full = path.join(dir, ent.name);
|
|
146
|
+
if (ent.isDirectory()) {
|
|
147
|
+
stack.push(full);
|
|
148
|
+
} else if (ent.name === binaryName) {
|
|
149
|
+
return full;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Ensure native binary is on disk; return absolute path.
|
|
158
|
+
* @param {string} version package version (must match GH release tag vX.Y.Z)
|
|
159
|
+
*/
|
|
160
|
+
async function ensureBinary(version) {
|
|
161
|
+
const { triple, isWindows, binaryName } = resolveTarget();
|
|
162
|
+
const dir = cacheDir(version, triple);
|
|
163
|
+
const binPath = path.join(dir, binaryName);
|
|
164
|
+
|
|
165
|
+
if (fs.existsSync(binPath)) {
|
|
166
|
+
return binPath;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// cargo-dist default artifact names (no version infix):
|
|
170
|
+
// mcp-better-aarch64-apple-darwin.tar.xz
|
|
171
|
+
// mcp-better-x86_64-pc-windows-msvc.zip
|
|
172
|
+
const ext = isWindows ? "zip" : "tar.xz";
|
|
173
|
+
const asset = `${APP}-${triple}.${ext}`;
|
|
174
|
+
// Also try .tar.gz (hand-rolled releases)
|
|
175
|
+
const candidates = isWindows
|
|
176
|
+
? [asset]
|
|
177
|
+
: [asset, `${APP}-${triple}.tar.gz`, `${APP}-v${version}-${triple}.tar.gz`];
|
|
178
|
+
|
|
179
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
180
|
+
const extractRoot = path.join(dir, "_extract");
|
|
181
|
+
fs.rmSync(extractRoot, { recursive: true, force: true });
|
|
182
|
+
fs.mkdirSync(extractRoot, { recursive: true });
|
|
183
|
+
|
|
184
|
+
let lastErr = null;
|
|
185
|
+
for (const name of candidates) {
|
|
186
|
+
const url = `https://github.com/${OWNER}/${REPO}/releases/download/v${version}/${name}`;
|
|
187
|
+
const archivePath = path.join(dir, name);
|
|
188
|
+
try {
|
|
189
|
+
process.stderr.write(`mcp-better: downloading ${name}…\n`);
|
|
190
|
+
await downloadFile(url, archivePath);
|
|
191
|
+
extractArchive(archivePath, extractRoot, isWindows);
|
|
192
|
+
const found = findBinary(extractRoot, binaryName);
|
|
193
|
+
if (!found) {
|
|
194
|
+
throw new Error(`archive ${name} did not contain ${binaryName}`);
|
|
195
|
+
}
|
|
196
|
+
fs.copyFileSync(found, binPath);
|
|
197
|
+
if (!isWindows) {
|
|
198
|
+
fs.chmodSync(binPath, 0o755);
|
|
199
|
+
}
|
|
200
|
+
// tidy
|
|
201
|
+
try {
|
|
202
|
+
fs.unlinkSync(archivePath);
|
|
203
|
+
} catch {
|
|
204
|
+
/* ignore */
|
|
205
|
+
}
|
|
206
|
+
fs.rmSync(extractRoot, { recursive: true, force: true });
|
|
207
|
+
return binPath;
|
|
208
|
+
} catch (err) {
|
|
209
|
+
lastErr = err;
|
|
210
|
+
try {
|
|
211
|
+
fs.unlinkSync(archivePath);
|
|
212
|
+
} catch {
|
|
213
|
+
/* ignore */
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
throw new Error(
|
|
219
|
+
`mcp-better: could not download a binary for ${triple} (v${version}). ` +
|
|
220
|
+
`Install Rust and run: cargo install mcp-better --version ${version}\n` +
|
|
221
|
+
`Last error: ${lastErr && lastErr.message ? lastErr.message : lastErr}`
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
module.exports = { ensureBinary, cacheDir };
|
package/lib/platform.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Map Node's process.platform / process.arch → Rust target triple
|
|
5
|
+
* used by cargo-dist / GitHub Release asset names.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const TARGETS = {
|
|
9
|
+
"darwin-arm64": "aarch64-apple-darwin",
|
|
10
|
+
"darwin-x64": "x86_64-apple-darwin",
|
|
11
|
+
"linux-arm64": "aarch64-unknown-linux-gnu",
|
|
12
|
+
"linux-x64": "x86_64-unknown-linux-gnu",
|
|
13
|
+
"win32-x64": "x86_64-pc-windows-msvc",
|
|
14
|
+
"win32-arm64": "aarch64-pc-windows-msvc",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @returns {{ triple: string, isWindows: boolean, binaryName: string }}
|
|
19
|
+
*/
|
|
20
|
+
function resolveTarget() {
|
|
21
|
+
const key = `${process.platform}-${process.arch}`;
|
|
22
|
+
const triple = TARGETS[key];
|
|
23
|
+
if (!triple) {
|
|
24
|
+
const supported = Object.keys(TARGETS).join(", ");
|
|
25
|
+
throw new Error(
|
|
26
|
+
`mcp-better: unsupported platform ${key}. Supported: ${supported}`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
const isWindows = process.platform === "win32";
|
|
30
|
+
return {
|
|
31
|
+
triple,
|
|
32
|
+
isWindows,
|
|
33
|
+
binaryName: isWindows ? "mcp-better.exe" : "mcp-better",
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = { resolveTarget, TARGETS };
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mcp-better",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "AAIF-verified modern MCP setup optimised to the 2026-07-28 model (BETTER textbook). npm shim downloads the native binary from GitHub Releases.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Wolfe-Jam <wolfejam@faf.one>",
|
|
7
|
+
"homepage": "https://github.com/Wolfe-Jam/mcp-better",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Wolfe-Jam/mcp-better.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Wolfe-Jam/mcp-better/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"mcp",
|
|
17
|
+
"model-context-protocol",
|
|
18
|
+
"rmcp",
|
|
19
|
+
"stdio",
|
|
20
|
+
"better"
|
|
21
|
+
],
|
|
22
|
+
"bin": {
|
|
23
|
+
"mcp-better": "bin/mcp-better.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"bin/",
|
|
27
|
+
"lib/",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18"
|
|
33
|
+
},
|
|
34
|
+
"os": [
|
|
35
|
+
"darwin",
|
|
36
|
+
"linux",
|
|
37
|
+
"win32"
|
|
38
|
+
],
|
|
39
|
+
"cpu": [
|
|
40
|
+
"x64",
|
|
41
|
+
"arm64"
|
|
42
|
+
]
|
|
43
|
+
}
|