gdep-mcp 0.1.0 → 0.1.3
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/gdep-mcp.js +55 -33
- package/bin/postinstall.js +74 -48
- package/package.json +1 -1
package/bin/gdep-mcp.js
CHANGED
|
@@ -1,57 +1,79 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* gdep-mcp — CLI entry point
|
|
4
|
-
*
|
|
5
|
-
* Usage:
|
|
6
|
-
* gdep-mcp
|
|
7
|
-
*
|
|
8
4
|
* Launches the gdep MCP server (Python).
|
|
9
|
-
*
|
|
10
|
-
* The Python gdep package must be installed: pip install gdep
|
|
5
|
+
* Usage: gdep-mcp
|
|
11
6
|
*/
|
|
12
7
|
|
|
13
|
-
const { spawn } = require('child_process');
|
|
14
|
-
const os
|
|
15
|
-
const fs
|
|
8
|
+
const { spawn, execSync } = require('child_process');
|
|
9
|
+
const os = require('os');
|
|
10
|
+
const fs = require('fs');
|
|
16
11
|
const path = require('path');
|
|
17
12
|
|
|
18
|
-
const
|
|
13
|
+
const isWin = os.platform() === 'win32';
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
// ── Find Python 3.11+ (same logic as postinstall) ─────────────
|
|
16
|
+
function findPython() {
|
|
17
|
+
const candidates = isWin
|
|
18
|
+
? ['py -3.11', 'py -3.12', 'py -3.13', 'python3.11', 'python3', 'python']
|
|
19
|
+
: ['python3.11', 'python3.12', 'python3.13', 'python3', 'python'];
|
|
20
|
+
|
|
21
|
+
for (const cmd of candidates) {
|
|
22
|
+
try {
|
|
23
|
+
const ver = execSync(`${cmd} --version`, { encoding: 'utf8', stdio: ['pipe','pipe','pipe'] }).trim();
|
|
24
|
+
const m = ver.match(/Python (\d+)\.(\d+)/);
|
|
25
|
+
if (m) {
|
|
26
|
+
const [, major, minor] = m.map(Number);
|
|
27
|
+
if (major === 3 && minor >= 11) return cmd;
|
|
28
|
+
}
|
|
29
|
+
} catch {}
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ── Find gdep MCP server.py via pip show ──────────────────────
|
|
35
|
+
function findServerScript(pyCmd) {
|
|
22
36
|
try {
|
|
23
|
-
const pipShow = execSync(`${pyCmd} -m pip show gdep`, { encoding: 'utf8' });
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
const candidate = path.join(locationMatch[1].trim(), 'gdep_mcp', 'server.py');
|
|
37
|
+
const pipShow = execSync(`${pyCmd} -m pip show gdep`, { encoding: 'utf8', stdio: ['pipe','pipe','pipe'] });
|
|
38
|
+
const m = pipShow.match(/Location: (.+)/);
|
|
39
|
+
if (m) {
|
|
40
|
+
const candidate = path.join(m[1].trim(), 'gdep_mcp', 'server.py');
|
|
28
41
|
if (fs.existsSync(candidate)) return candidate;
|
|
42
|
+
// Also try gdep-mcp subdir
|
|
43
|
+
const candidate2 = path.join(m[1].trim(), 'gdep', 'gdep-mcp', 'server.py');
|
|
44
|
+
if (fs.existsSync(candidate2)) return candidate2;
|
|
29
45
|
}
|
|
30
46
|
} catch {}
|
|
31
47
|
return null;
|
|
32
48
|
}
|
|
33
49
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
stdio: 'inherit',
|
|
40
|
-
env: { ...process.env, PYTHONUTF8: '1' },
|
|
41
|
-
});
|
|
42
|
-
} else {
|
|
43
|
-
child = spawn(pyCmd, ['-m', 'gdep_mcp.server'], {
|
|
44
|
-
stdio: 'inherit',
|
|
45
|
-
env: { ...process.env, PYTHONUTF8: '1' },
|
|
46
|
-
});
|
|
50
|
+
const pyCmd = findPython();
|
|
51
|
+
if (!pyCmd) {
|
|
52
|
+
console.error('Python 3.11+ not found. Install gdep manually:');
|
|
53
|
+
console.error(' pip install gdep "mcp[cli]"');
|
|
54
|
+
process.exit(1);
|
|
47
55
|
}
|
|
48
56
|
|
|
57
|
+
// Split "py -3.11" into ["py", "-3.11"]
|
|
58
|
+
const cmdParts = pyCmd.split(' ');
|
|
59
|
+
const pyExe = cmdParts[0];
|
|
60
|
+
const pyExtraArgs= cmdParts.slice(1);
|
|
61
|
+
|
|
62
|
+
const serverScript = findServerScript(pyCmd);
|
|
63
|
+
const spawnArgs = serverScript
|
|
64
|
+
? [...pyExtraArgs, serverScript]
|
|
65
|
+
: [...pyExtraArgs, '-m', 'gdep_mcp.server'];
|
|
66
|
+
|
|
67
|
+
const child = spawn(pyExe, spawnArgs, {
|
|
68
|
+
stdio: 'inherit',
|
|
69
|
+
shell: isWin,
|
|
70
|
+
env: { ...process.env, PYTHONUTF8: '1' },
|
|
71
|
+
});
|
|
72
|
+
|
|
49
73
|
child.on('error', (err) => {
|
|
50
74
|
console.error(`Failed to start gdep MCP server: ${err.message}`);
|
|
51
75
|
console.error('Make sure gdep is installed: pip install gdep "mcp[cli]"');
|
|
52
76
|
process.exit(1);
|
|
53
77
|
});
|
|
54
78
|
|
|
55
|
-
child.on('exit', (code) =>
|
|
56
|
-
process.exit(code ?? 0);
|
|
57
|
-
});
|
|
79
|
+
child.on('exit', (code) => process.exit(code ?? 0));
|
package/bin/postinstall.js
CHANGED
|
@@ -1,85 +1,111 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* gdep-mcp — postinstall script
|
|
4
|
-
*
|
|
5
|
-
* Automatically installs the gdep Python package and MCP dependencies
|
|
6
|
-
* after `npm install -g gdep-mcp`.
|
|
7
|
-
*
|
|
8
|
-
* Steps:
|
|
9
|
-
* 1. Check Python 3.11+ is available
|
|
10
|
-
* 2. pip install gdep (from PyPI)
|
|
11
|
-
* 3. pip install "mcp[cli]"
|
|
12
|
-
* 4. Print Claude Desktop config snippet
|
|
4
|
+
* Installs the gdep Python package after `npm install -g gdep-mcp`.
|
|
13
5
|
*/
|
|
14
6
|
|
|
15
7
|
const { execSync, spawnSync } = require('child_process');
|
|
16
|
-
const path = require('path');
|
|
17
8
|
const os = require('os');
|
|
18
9
|
|
|
19
|
-
const BOLD
|
|
10
|
+
const BOLD = '\x1b[1m';
|
|
20
11
|
const GREEN = '\x1b[32m';
|
|
21
|
-
const YELLOW
|
|
22
|
-
const CYAN
|
|
12
|
+
const YELLOW= '\x1b[33m';
|
|
13
|
+
const CYAN = '\x1b[36m';
|
|
23
14
|
const RESET = '\x1b[0m';
|
|
24
15
|
|
|
25
|
-
function log(msg) { console.log(msg); }
|
|
26
16
|
function ok(msg) { console.log(`${GREEN}✓${RESET} ${msg}`); }
|
|
27
17
|
function warn(msg) { console.log(`${YELLOW}⚠${RESET} ${msg}`); }
|
|
28
18
|
function info(msg) { console.log(`${CYAN}→${RESET} ${msg}`); }
|
|
29
19
|
|
|
30
|
-
log(`\n${BOLD}gdep-mcp postinstall${RESET}\n`);
|
|
20
|
+
console.log(`\n${BOLD}gdep-mcp postinstall${RESET}\n`);
|
|
31
21
|
|
|
32
|
-
// ── 1. Python
|
|
33
|
-
|
|
22
|
+
// ── 1. Find Python 3.11+ ──────────────────────────────────────
|
|
23
|
+
// Try candidates in order: py -3.11 (Windows launcher), python3.11, python3, python
|
|
24
|
+
const isWin = os.platform() === 'win32';
|
|
25
|
+
const candidates = isWin
|
|
26
|
+
? ['py -3.11', 'py -3.12', 'py -3.13', 'python3.11', 'python3', 'python']
|
|
27
|
+
: ['python3.11', 'python3.12', 'python3.13', 'python3', 'python'];
|
|
28
|
+
|
|
29
|
+
let pyCmd = null;
|
|
34
30
|
let pyVersion = null;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
|
|
32
|
+
for (const cmd of candidates) {
|
|
33
|
+
try {
|
|
34
|
+
const ver = execSync(`${cmd} --version`, { encoding: 'utf8', stdio: ['pipe','pipe','pipe'] }).trim();
|
|
35
|
+
const m = ver.match(/Python (\d+)\.(\d+)/);
|
|
36
|
+
if (m) {
|
|
37
|
+
const [, major, minor] = m.map(Number);
|
|
38
|
+
if (major === 3 && minor >= 11) {
|
|
39
|
+
pyCmd = cmd;
|
|
40
|
+
pyVersion = ver;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} catch {}
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
process.exit(0);
|
|
50
|
-
}
|
|
47
|
+
if (!pyCmd) {
|
|
48
|
+
warn('Python 3.11+ not found. Please install it and run manually:');
|
|
49
|
+
warn(' pip install gdep "mcp[cli]"');
|
|
50
|
+
warn(' Download: https://www.python.org/downloads/');
|
|
51
|
+
process.exit(0);
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
shell: true,
|
|
58
|
-
});
|
|
54
|
+
ok(`Python found: ${pyVersion} (using: ${pyCmd})`);
|
|
55
|
+
|
|
56
|
+
// ── 2. pip install gdep + mcp[cli] ────────────────────────────
|
|
57
|
+
info('Installing gdep and mcp[cli]...');
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
// For "py -3.11" style commands, split into args
|
|
60
|
+
const cmdParts = pyCmd.split(' ');
|
|
61
|
+
const pipArgs = [...cmdParts.slice(1), '-m', 'pip', 'install', '--upgrade', 'gdep', 'mcp[cli]'];
|
|
62
|
+
|
|
63
|
+
const result = spawnSync(cmdParts[0], pipArgs, { stdio: 'inherit', shell: isWin });
|
|
64
|
+
|
|
65
|
+
if (result.status !== 0) {
|
|
66
|
+
warn('pip install failed. Try manually:');
|
|
67
|
+
warn(` ${pyCmd} -m pip install gdep "mcp[cli]"`);
|
|
62
68
|
process.exit(0);
|
|
63
69
|
}
|
|
64
|
-
ok('gdep and mcp[cli] installed successfully.');
|
|
65
70
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
ok('gdep and mcp[cli] installed!');
|
|
72
|
+
|
|
73
|
+
// ── 3. Check gdep is on PATH ──────────────────────────────────
|
|
74
|
+
try {
|
|
75
|
+
execSync('gdep --help', { stdio: 'pipe' });
|
|
76
|
+
ok('gdep command is available on PATH.');
|
|
77
|
+
} catch {
|
|
78
|
+
warn('gdep was installed but is not on PATH.');
|
|
79
|
+
warn('Add the Python Scripts folder to your PATH, e.g.:');
|
|
80
|
+
if (isWin) {
|
|
81
|
+
// Try to find the actual scripts path
|
|
82
|
+
try {
|
|
83
|
+
const scripts = execSync(`${pyCmd} -c "import sysconfig; print(sysconfig.get_path('scripts'))"`,
|
|
84
|
+
{ encoding: 'utf8', stdio: ['pipe','pipe','pipe'] }).trim();
|
|
85
|
+
warn(` ${scripts}`);
|
|
86
|
+
} catch {}
|
|
87
|
+
warn(' (System Properties → Environment Variables → Path)');
|
|
88
|
+
} else {
|
|
89
|
+
warn(' export PATH="$PATH:$(python3 -m site --user-base)/bin"');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ── 3. Print config ───────────────────────────────────────────
|
|
94
|
+
console.log(`
|
|
69
95
|
${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}
|
|
70
|
-
${GREEN}${BOLD} gdep-mcp
|
|
96
|
+
${GREEN}${BOLD} gdep-mcp ready!${RESET}
|
|
71
97
|
|
|
72
|
-
Add
|
|
73
|
-
(claude_desktop_config.json):
|
|
98
|
+
Add to Claude Desktop (claude_desktop_config.json):
|
|
74
99
|
|
|
75
100
|
${CYAN}{
|
|
76
101
|
"mcpServers": {
|
|
77
102
|
"gdep": {
|
|
78
|
-
"command": "gdep-mcp"
|
|
79
|
-
"args": ["/path/to/your/game/project"]
|
|
103
|
+
"command": "gdep-mcp"
|
|
80
104
|
}
|
|
81
105
|
}
|
|
82
106
|
}${RESET}
|
|
83
107
|
|
|
108
|
+
Each tool call passes project_path as a parameter.
|
|
109
|
+
|
|
84
110
|
${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}
|
|
85
111
|
`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gdep-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "MCP server for gdep — Game Codebase Analysis Tool (Unity/UE5/C++/C#)",
|
|
5
5
|
"keywords": ["mcp", "game", "unity", "unreal", "ue5", "dependency", "analysis", "claude", "cursor", "ai"],
|
|
6
6
|
"author": "pirua-game",
|