docbrain-mcp 0.2.2
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/install.js +62 -0
- package/package.json +39 -0
- package/run.js +31 -0
package/install.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const https = require("https");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const os = require("os");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
|
|
9
|
+
const VERSION = require("./package.json").version;
|
|
10
|
+
|
|
11
|
+
const PLATFORM_MAP = { darwin: "darwin", linux: "linux" };
|
|
12
|
+
const ARCH_MAP = { x64: "amd64", arm64: "arm64" };
|
|
13
|
+
|
|
14
|
+
const platform = PLATFORM_MAP[os.platform()];
|
|
15
|
+
const arch = ARCH_MAP[os.arch()];
|
|
16
|
+
|
|
17
|
+
if (!platform || !arch) {
|
|
18
|
+
console.error(
|
|
19
|
+
`Unsupported platform: ${os.platform()}-${os.arch()}. DocBrain MCP server supports macOS and Linux (x64, arm64).`
|
|
20
|
+
);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const binaryName = `docbrain-mcp-${platform}-${arch}`;
|
|
25
|
+
const url = `https://github.com/docbrain-ai/docbrain/releases/download/v${VERSION}/${binaryName}`;
|
|
26
|
+
const binDir = path.join(__dirname, "bin");
|
|
27
|
+
const dest = path.join(binDir, "docbrain-mcp");
|
|
28
|
+
|
|
29
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
30
|
+
|
|
31
|
+
function download(url) {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
https
|
|
34
|
+
.get(url, (res) => {
|
|
35
|
+
// GitHub releases redirect to S3
|
|
36
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
37
|
+
return download(res.headers.location).then(resolve).catch(reject);
|
|
38
|
+
}
|
|
39
|
+
if (res.statusCode !== 200) {
|
|
40
|
+
reject(new Error(`Download failed: HTTP ${res.statusCode}`));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const file = fs.createWriteStream(dest);
|
|
44
|
+
res.pipe(file);
|
|
45
|
+
file.on("finish", () => {
|
|
46
|
+
file.close();
|
|
47
|
+
fs.chmodSync(dest, 0o755);
|
|
48
|
+
resolve();
|
|
49
|
+
});
|
|
50
|
+
file.on("error", reject);
|
|
51
|
+
})
|
|
52
|
+
.on("error", reject);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
download(url)
|
|
57
|
+
.then(() => console.log(`DocBrain MCP server v${VERSION} installed (${platform}/${arch})`))
|
|
58
|
+
.catch((err) => {
|
|
59
|
+
console.error(`Failed to install DocBrain MCP server: ${err.message}`);
|
|
60
|
+
console.error(`You can download manually from: https://github.com/docbrain-ai/docbrain/releases`);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "docbrain-mcp",
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "DocBrain MCP server — query your documentation from Claude Code, Cursor, and any MCP-compatible editor",
|
|
5
|
+
"homepage": "https://github.com/docbrain-ai/docbrain",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/docbrain-ai/docbrain.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "BSL-1.1",
|
|
11
|
+
"bin": {
|
|
12
|
+
"docbrain-mcp": "run.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"postinstall": "node install.js"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"docbrain",
|
|
19
|
+
"mcp",
|
|
20
|
+
"model-context-protocol",
|
|
21
|
+
"documentation",
|
|
22
|
+
"rag",
|
|
23
|
+
"ai",
|
|
24
|
+
"claude",
|
|
25
|
+
"cursor"
|
|
26
|
+
],
|
|
27
|
+
"os": [
|
|
28
|
+
"darwin",
|
|
29
|
+
"linux"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=16"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"run.js",
|
|
36
|
+
"install.js",
|
|
37
|
+
"bin/"
|
|
38
|
+
]
|
|
39
|
+
}
|
package/run.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { spawn } = require("child_process");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
|
|
7
|
+
const binary = path.join(__dirname, "bin", "docbrain-mcp");
|
|
8
|
+
|
|
9
|
+
const child = spawn(binary, process.argv.slice(2), {
|
|
10
|
+
stdio: "inherit",
|
|
11
|
+
env: process.env,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// Forward signals so the MCP server shuts down cleanly
|
|
15
|
+
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
|
|
16
|
+
process.on(signal, () => child.kill(signal));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
child.on("exit", (code, signal) => {
|
|
20
|
+
if (signal) {
|
|
21
|
+
process.kill(process.pid, signal);
|
|
22
|
+
} else {
|
|
23
|
+
process.exit(code ?? 1);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
child.on("error", (err) => {
|
|
28
|
+
console.error(`Failed to run DocBrain MCP server: ${err.message}`);
|
|
29
|
+
console.error("Try reinstalling: npx -y docbrain-mcp@latest");
|
|
30
|
+
process.exit(1);
|
|
31
|
+
});
|