@volute_cvc/cvc-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.
- package/bin/cvc-mcp.js +116 -0
- package/package.json +20 -0
package/bin/cvc-mcp.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const os = require('os');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const https = require('https');
|
|
7
|
+
const child_process = require('child_process');
|
|
8
|
+
|
|
9
|
+
const CACHE_DIR = path.join(os.homedir(), '.cvc', 'mcp-cache');
|
|
10
|
+
|
|
11
|
+
function getPlatformDetails() {
|
|
12
|
+
const platform = os.platform();
|
|
13
|
+
const arch = os.arch();
|
|
14
|
+
|
|
15
|
+
let osTag = '';
|
|
16
|
+
let archTag = '';
|
|
17
|
+
|
|
18
|
+
// Determine OS Tag
|
|
19
|
+
if (platform === 'linux') {
|
|
20
|
+
osTag = 'unknown-linux-gnu';
|
|
21
|
+
} else if (platform === 'darwin') {
|
|
22
|
+
osTag = 'apple-darwin';
|
|
23
|
+
} else if (platform === 'win32') {
|
|
24
|
+
osTag = 'pc-windows-msvc';
|
|
25
|
+
} else {
|
|
26
|
+
console.error(`Unsupported OS: ${platform}`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Determine Arch Tag
|
|
31
|
+
if (arch === 'x64') {
|
|
32
|
+
archTag = 'x86_64';
|
|
33
|
+
} else if (arch === 'arm64' || arch === 'aarch64') {
|
|
34
|
+
archTag = 'aarch64';
|
|
35
|
+
} else {
|
|
36
|
+
console.error(`Unsupported Architecture: ${arch}`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return { platform, osTag, archTag };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function download(url, dest) {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
const file = fs.createWriteStream(dest);
|
|
46
|
+
https.get(url, (response) => {
|
|
47
|
+
if (response.statusCode === 301 || response.statusCode === 302) {
|
|
48
|
+
return download(response.headers.location, dest).then(resolve).catch(reject);
|
|
49
|
+
}
|
|
50
|
+
if (response.statusCode !== 200) {
|
|
51
|
+
return reject(new Error(`Failed to download ${url}: ${response.statusCode}`));
|
|
52
|
+
}
|
|
53
|
+
response.pipe(file);
|
|
54
|
+
file.on('finish', () => {
|
|
55
|
+
file.close(resolve);
|
|
56
|
+
});
|
|
57
|
+
}).on('error', (err) => {
|
|
58
|
+
fs.unlink(dest, () => reject(err));
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function extract(archivePath, destDir, platform) {
|
|
64
|
+
if (platform === 'win32') {
|
|
65
|
+
// Basic unzipping on windows using powershell
|
|
66
|
+
child_process.execSync(`powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${destDir}' -Force"`, { stdio: 'inherit' });
|
|
67
|
+
} else {
|
|
68
|
+
// Assuming tar is available on Unix
|
|
69
|
+
child_process.execSync(`tar -xzf "${archivePath}" -C "${destDir}"`, { stdio: 'inherit' });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function main() {
|
|
74
|
+
const { platform, osTag, archTag } = getPlatformDetails();
|
|
75
|
+
const ext = platform === 'win32' ? 'zip' : 'tar.gz';
|
|
76
|
+
const binName = platform === 'win32' ? 'cvc-mcp.exe' : 'cvc-mcp';
|
|
77
|
+
const assetName = `cvc-${archTag}-${osTag}.${ext}`;
|
|
78
|
+
const downloadUrl = `https://cvc.dev/api/download/${assetName}`;
|
|
79
|
+
|
|
80
|
+
const binPath = path.join(CACHE_DIR, binName);
|
|
81
|
+
|
|
82
|
+
if (!fs.existsSync(binPath)) {
|
|
83
|
+
console.error(`CVC MCP not found locally. Downloading from ${downloadUrl}...`);
|
|
84
|
+
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
|
85
|
+
const tmpArchive = path.join(CACHE_DIR, assetName);
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
await download(downloadUrl, tmpArchive);
|
|
89
|
+
console.error('Extracting...');
|
|
90
|
+
extract(tmpArchive, CACHE_DIR, platform);
|
|
91
|
+
fs.unlinkSync(tmpArchive); // Clean up archive
|
|
92
|
+
if (platform !== 'win32') {
|
|
93
|
+
fs.chmodSync(binPath, 0o755);
|
|
94
|
+
}
|
|
95
|
+
console.error('Download and extraction complete.');
|
|
96
|
+
} catch (e) {
|
|
97
|
+
console.error(`Failed to install CVC MCP: ${e.message}`);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Execute the binary
|
|
103
|
+
const args = process.argv.slice(2);
|
|
104
|
+
const child = child_process.spawn(binPath, args, {
|
|
105
|
+
stdio: 'inherit'
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
child.on('close', (code) => {
|
|
109
|
+
process.exit(code);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
main().catch(e => {
|
|
114
|
+
console.error(e);
|
|
115
|
+
process.exit(1);
|
|
116
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@volute_cvc/cvc-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CVC Model Context Protocol Server",
|
|
5
|
+
"bin": {
|
|
6
|
+
"cvc-mcp": "./bin/cvc-mcp.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/meirka8/cvc.git"
|
|
14
|
+
},
|
|
15
|
+
"author": "Volute",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
}
|
|
20
|
+
}
|