@campfire-net/campfire-mcp 0.1.0 → 0.1.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/index.js +39 -14
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
const { execFileSync } = require('child_process');
|
|
4
|
+
const { execFileSync, execSync } = require('child_process');
|
|
5
5
|
const path = require('path');
|
|
6
|
+
const fs = require('fs');
|
|
6
7
|
const os = require('os');
|
|
7
8
|
|
|
8
9
|
function getBinaryPath() {
|
|
9
|
-
const platform = os.platform();
|
|
10
|
-
const arch = os.arch();
|
|
10
|
+
const platform = os.platform();
|
|
11
|
+
const arch = os.arch();
|
|
11
12
|
|
|
12
13
|
const pkgMap = {
|
|
13
|
-
'linux-x64': 'campfire-mcp-linux-x64',
|
|
14
|
-
'linux-arm64': 'campfire-mcp-linux-arm64',
|
|
15
|
-
'darwin-x64': 'campfire-mcp-darwin-x64',
|
|
16
|
-
'darwin-arm64': 'campfire-mcp-darwin-arm64',
|
|
17
|
-
'win32-x64': 'campfire-mcp-win32-x64',
|
|
14
|
+
'linux-x64': '@campfire-net/campfire-mcp-linux-x64',
|
|
15
|
+
'linux-arm64': '@campfire-net/campfire-mcp-linux-arm64',
|
|
16
|
+
'darwin-x64': '@campfire-net/campfire-mcp-darwin-x64',
|
|
17
|
+
'darwin-arm64': '@campfire-net/campfire-mcp-darwin-arm64',
|
|
18
|
+
'win32-x64': '@campfire-net/campfire-mcp-win32-x64',
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
const key = `${platform}-${arch}`;
|
|
@@ -23,18 +24,42 @@ function getBinaryPath() {
|
|
|
23
24
|
throw new Error(`campfire-mcp: unsupported platform ${key}`);
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
// Try platform package first
|
|
26
28
|
try {
|
|
27
29
|
const pkgDir = path.dirname(require.resolve(`${pkgName}/package.json`));
|
|
28
30
|
const bin = platform === 'win32'
|
|
29
31
|
? path.join(pkgDir, 'cf-mcp.exe')
|
|
30
32
|
: path.join(pkgDir, 'cf-mcp');
|
|
31
|
-
return bin;
|
|
32
|
-
} catch {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
if (fs.existsSync(bin)) return bin;
|
|
34
|
+
} catch {}
|
|
35
|
+
|
|
36
|
+
// Fallback: check cache
|
|
37
|
+
const cacheDir = path.join(os.homedir(), '.cache', 'campfire-mcp');
|
|
38
|
+
const cachedBin = path.join(cacheDir, platform === 'win32' ? 'cf-mcp.exe' : 'cf-mcp');
|
|
39
|
+
if (fs.existsSync(cachedBin)) return cachedBin;
|
|
40
|
+
|
|
41
|
+
// Download from GitHub Releases
|
|
42
|
+
const goArch = arch === 'x64' ? 'amd64' : arch;
|
|
43
|
+
const goPlatform = platform;
|
|
44
|
+
const ext = platform === 'win32' ? 'zip' : 'tar.gz';
|
|
45
|
+
const url = `https://github.com/campfire-net/campfire/releases/latest/download/cf_${goPlatform}_${goArch}.${ext}`;
|
|
46
|
+
|
|
47
|
+
process.stderr.write(`campfire-mcp: downloading binary from ${url}\n`);
|
|
48
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
if (platform === 'win32') {
|
|
52
|
+
execSync(`curl -sL "${url}" -o "${cacheDir}/cf.zip" && cd "${cacheDir}" && tar -xf cf.zip cf-mcp.exe`, { stdio: 'pipe' });
|
|
53
|
+
} else {
|
|
54
|
+
execSync(`curl -sL "${url}" | tar xz -C "${cacheDir}" --strip-components=1 --wildcards '*/cf-mcp'`, { stdio: 'pipe' });
|
|
55
|
+
}
|
|
56
|
+
fs.chmodSync(cachedBin, 0o755);
|
|
57
|
+
if (fs.existsSync(cachedBin)) return cachedBin;
|
|
58
|
+
} catch (e) {
|
|
59
|
+
throw new Error(`campfire-mcp: failed to download binary: ${e.message}\nInstall manually: curl -fsSL https://getcampfire.dev/install.sh | sh`);
|
|
37
60
|
}
|
|
61
|
+
|
|
62
|
+
throw new Error('campfire-mcp: could not find or download binary');
|
|
38
63
|
}
|
|
39
64
|
|
|
40
65
|
try {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@campfire-net/campfire-mcp",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Campfire MCP server
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Campfire MCP server — decentralized coordination protocol for AI agents",
|
|
5
5
|
"bin": {
|
|
6
6
|
"campfire-mcp": "index.js"
|
|
7
7
|
},
|