ssumcp 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/ssumcp.js +118 -0
- package/package.json +35 -0
package/bin/ssumcp.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const { execSync, spawn } = require('child_process');
|
|
6
|
+
const { existsSync, mkdirSync, createWriteStream, unlinkSync } = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const os = require('os');
|
|
9
|
+
const https = require('https');
|
|
10
|
+
|
|
11
|
+
const { version } = require('../package.json');
|
|
12
|
+
const REPO = 'hoeongj/ssuMCP';
|
|
13
|
+
const JAR_NAME = `ssuMCP-${version}.jar`;
|
|
14
|
+
const JAR_URL = `https://github.com/${REPO}/releases/download/v${version}/${JAR_NAME}`;
|
|
15
|
+
const CACHE_DIR = path.join(os.homedir(), '.ssumcp');
|
|
16
|
+
const JAR_PATH = path.join(CACHE_DIR, JAR_NAME);
|
|
17
|
+
|
|
18
|
+
function checkJava() {
|
|
19
|
+
try {
|
|
20
|
+
const output = execSync('java -version 2>&1', { encoding: 'utf8' });
|
|
21
|
+
const match = output.match(/version "(\d+)/);
|
|
22
|
+
const major = match ? parseInt(match[1], 10) : 0;
|
|
23
|
+
if (major < 21) {
|
|
24
|
+
console.error(`[ssumcp] Java 21 이상이 필요합니다. 현재: Java ${major}`);
|
|
25
|
+
console.error('[ssumcp] 설치: https://adoptium.net');
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
} catch {
|
|
29
|
+
console.error('[ssumcp] Java가 설치되어 있지 않습니다.');
|
|
30
|
+
console.error('[ssumcp] Java 21 설치: https://adoptium.net');
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function downloadJar() {
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
if (existsSync(JAR_PATH)) {
|
|
38
|
+
resolve();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!existsSync(CACHE_DIR)) {
|
|
43
|
+
mkdirSync(CACHE_DIR, { recursive: true });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
console.log(`[ssumcp] ssuMCP v${version} 다운로드 중...`);
|
|
47
|
+
|
|
48
|
+
const file = createWriteStream(JAR_PATH);
|
|
49
|
+
|
|
50
|
+
function get(url, hops) {
|
|
51
|
+
if (hops > 5) { reject(new Error('리다이렉트 초과')); return; }
|
|
52
|
+
https.get(url, (res) => {
|
|
53
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
54
|
+
get(res.headers.location, hops + 1);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (res.statusCode !== 200) {
|
|
58
|
+
file.close();
|
|
59
|
+
try { unlinkSync(JAR_PATH); } catch { /* ignore */ }
|
|
60
|
+
reject(new Error(
|
|
61
|
+
`다운로드 실패: HTTP ${res.statusCode}\n` +
|
|
62
|
+
`릴리즈 확인: https://github.com/${REPO}/releases`
|
|
63
|
+
));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const total = parseInt(res.headers['content-length'] || '0', 10);
|
|
67
|
+
let done = 0;
|
|
68
|
+
res.on('data', (chunk) => {
|
|
69
|
+
done += chunk.length;
|
|
70
|
+
if (total > 0) {
|
|
71
|
+
process.stdout.write(`\r[ssumcp] ${Math.round((done / total) * 100)}%`);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
res.pipe(file);
|
|
75
|
+
file.on('finish', () => { file.close(); process.stdout.write('\n'); resolve(); });
|
|
76
|
+
}).on('error', (err) => {
|
|
77
|
+
file.close();
|
|
78
|
+
try { unlinkSync(JAR_PATH); } catch { /* ignore */ }
|
|
79
|
+
reject(err);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
get(JAR_URL, 0);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function main() {
|
|
88
|
+
checkJava();
|
|
89
|
+
await downloadJar();
|
|
90
|
+
|
|
91
|
+
const port = process.env.PORT || '8080';
|
|
92
|
+
const extra = process.argv.slice(2);
|
|
93
|
+
|
|
94
|
+
console.log(`[ssumcp] 서버 시작 중 (포트 ${port})...`);
|
|
95
|
+
console.log(`[ssumcp] MCP 엔드포인트 → http://localhost:${port}/mcp`);
|
|
96
|
+
console.log('');
|
|
97
|
+
console.log('Claude Desktop 설정 (claude_desktop_config.json):');
|
|
98
|
+
console.log(JSON.stringify(
|
|
99
|
+
{ mcpServers: { ssuMCP: { url: `http://localhost:${port}/mcp` } } },
|
|
100
|
+
null, 2
|
|
101
|
+
));
|
|
102
|
+
console.log('');
|
|
103
|
+
|
|
104
|
+
const child = spawn(
|
|
105
|
+
'java',
|
|
106
|
+
[`-Dserver.port=${port}`, '-jar', JAR_PATH, ...extra],
|
|
107
|
+
{ stdio: 'inherit' }
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
process.on('SIGINT', () => child.kill('SIGINT'));
|
|
111
|
+
process.on('SIGTERM', () => child.kill('SIGTERM'));
|
|
112
|
+
child.on('exit', (code) => process.exit(code ?? 0));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
main().catch((err) => {
|
|
116
|
+
console.error('[ssumcp] 오류:', err.message);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ssumcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "숭실대학교 MCP 서버 — Soongsil University MCP server for Claude, Cursor and other MCP clients",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"model-context-protocol",
|
|
8
|
+
"soongsil",
|
|
9
|
+
"ssu",
|
|
10
|
+
"university",
|
|
11
|
+
"korea",
|
|
12
|
+
"claude",
|
|
13
|
+
"cursor",
|
|
14
|
+
"ai"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://github.com/hoeongj/ssuMCP",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/hoeongj/ssuMCP.git",
|
|
20
|
+
"directory": "npm"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/hoeongj/ssuMCP/issues"
|
|
24
|
+
},
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"bin": {
|
|
27
|
+
"ssumcp": "bin/ssumcp.js"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"bin/"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
}
|
|
35
|
+
}
|