@letoribo/mcpgql 1.0.0 → 1.0.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/core.ts +69 -0
- package/index.js +5 -2
- package/package.json +5 -4
package/core.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env npx tsx
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
import * as readline from 'readline';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
|
|
7
|
+
const rl = readline.createInterface({
|
|
8
|
+
input: process.stdin,
|
|
9
|
+
output: process.stdout
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
function getDistPath(): string {
|
|
13
|
+
// 1. Try to find dist/index.js by traversing up from the current directory
|
|
14
|
+
let current = process.cwd();
|
|
15
|
+
|
|
16
|
+
while (true) {
|
|
17
|
+
const candidate = path.join(current, 'mcp-graphql-enhanced', 'dist', 'index.js');
|
|
18
|
+
if (fs.existsSync(candidate)) {
|
|
19
|
+
console.log(`[INFO] Found local project version: ${candidate}`);
|
|
20
|
+
return candidate;
|
|
21
|
+
}
|
|
22
|
+
const parent = path.dirname(current);
|
|
23
|
+
if (parent === current) break; // Reached filesystem root
|
|
24
|
+
current = parent;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 2. If not found locally, use the version installed in node_modules
|
|
28
|
+
console.log(`[INFO] Local build not found, using installed version.`);
|
|
29
|
+
return path.join(
|
|
30
|
+
path.dirname(require.resolve('@letoribo/mcp-graphql-enhanced/package.json')),
|
|
31
|
+
'dist/index.js'
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
console.log('\n--- MCP GraphQL Enhanced CLI ---');
|
|
36
|
+
console.log('1. Terminal (HTTP GraphQL Gateway)');
|
|
37
|
+
console.log('2. MCP Inspector (stdio)');
|
|
38
|
+
|
|
39
|
+
rl.question('\nSelect mode (1 or 2): ', (answer) => {
|
|
40
|
+
if (answer !== '1' && answer !== '2') {
|
|
41
|
+
console.log('Invalid selection. Please enter 1 or 2.');
|
|
42
|
+
rl.close();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const distPath = getDistPath();
|
|
47
|
+
|
|
48
|
+
if (!fs.existsSync(distPath)) {
|
|
49
|
+
console.error(`\n[ERROR] Build file not found at: ${distPath}`);
|
|
50
|
+
console.error('Please ensure the project is compiled (npm run build).');
|
|
51
|
+
rl.close();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (answer === '1') {
|
|
56
|
+
process.env.ENABLE_HTTP = 'true';
|
|
57
|
+
console.log(`Launching...`);
|
|
58
|
+
// Run with the current working directory to ensure config files are picked up
|
|
59
|
+
spawn('node', [distPath], { stdio: 'inherit', cwd: process.cwd() });
|
|
60
|
+
} else {
|
|
61
|
+
console.log('Launching in Inspector mode...');
|
|
62
|
+
spawn('npx', ['-y', '@modelcontextprotocol/inspector', 'node', distPath], {
|
|
63
|
+
stdio: 'inherit',
|
|
64
|
+
cwd: process.cwd()
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
rl.close();
|
|
69
|
+
});
|
package/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const {
|
|
2
|
+
const { spawnSync } = require('child_process');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
|
|
5
5
|
const pathToCore = path.join(__dirname, 'core.ts');
|
|
6
|
-
|
|
6
|
+
spawnSync('npx', ['tsx', pathToCore], {
|
|
7
|
+
stdio: 'inherit',
|
|
8
|
+
shell: true
|
|
9
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@letoribo/mcpgql",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "CLI tool for MCP GraphQL Enhanced",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"index.js",
|
|
11
|
-
"
|
|
11
|
+
"core.ts"
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
14
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -16,9 +16,10 @@
|
|
|
16
16
|
"author": "letoribo",
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"tsx": "^4.0.0"
|
|
19
|
+
"tsx": "^4.0.0",
|
|
20
|
+
"@letoribo/mcp-graphql-enhanced": "latest"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
23
|
"@types/node": "^26.1.1"
|
|
23
24
|
}
|
|
24
|
-
}
|
|
25
|
+
}
|