@letoribo/mcpgql 1.0.1 → 1.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/core.ts ADDED
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env npx tsx
2
+ import { spawn } from 'child_process';
3
+ import * as readline from 'readline/promises';
4
+ import { stdin as input, stdout as output } from 'process';
5
+ import * as path from 'path';
6
+ import * as fs from 'fs';
7
+
8
+ // --- Interfaces ---
9
+ interface Config {
10
+ activeEndpoints: string[];
11
+ endpoints: Record<string, string>;
12
+ }
13
+
14
+ // --- Initialization ---
15
+ const rl = readline.createInterface({ input, output });
16
+
17
+ const configPath = path.join(process.cwd(), 'mcpgql.config.json');
18
+ const config: Config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
19
+ const entries: [string, string][] = Object.entries(config.endpoints);
20
+
21
+ // Default: first endpoint is selected
22
+ const selected = new Set<string>();
23
+ if (entries.length > 0) selected.add(entries[0][0]);
24
+
25
+ function getDistPath(): string {
26
+ let current = process.cwd();
27
+ while (true) {
28
+ const candidate = path.join(current, 'mcp-graphql-enhanced', 'dist', 'index.js');
29
+ if (fs.existsSync(candidate)) return candidate;
30
+ const parent = path.dirname(current);
31
+ if (parent === current) break;
32
+ current = parent;
33
+ }
34
+ return path.join(
35
+ path.dirname(require.resolve('@letoribo/mcp-graphql-enhanced/package.json')),
36
+ 'dist/index.js'
37
+ );
38
+ }
39
+
40
+ // --- Core Logic ---
41
+ async function startSelection() {
42
+ while (true) {
43
+ console.clear();
44
+ console.log('\n--- Select Endpoints (Enter to confirm) ---');
45
+ entries.forEach(([key], i) => {
46
+ console.log(`${selected.has(key) ? ' [✓] ' : ' [ ] '} ${i + 1}. ${key}`);
47
+ });
48
+
49
+ const choice = await rl.question('\nEnter number to toggle (or Enter to proceed): ');
50
+
51
+ if (choice.trim() === '') break;
52
+
53
+ const idx = parseInt(choice.trim()) - 1;
54
+ if (idx >= 0 && idx < entries.length) {
55
+ const key = entries[idx][0];
56
+ selected.has(key) ? selected.delete(key) : selected.add(key);
57
+ }
58
+ }
59
+ }
60
+
61
+ async function main() {
62
+ await startSelection();
63
+
64
+ const selectedUrls = Array.from(selected).map(k => config.endpoints[k]);
65
+ if (selectedUrls.length === 0) {
66
+ console.log('[ERROR] No endpoints selected.');
67
+ rl.close();
68
+ process.exit(1);
69
+ }
70
+
71
+ console.log('\n1. Terminal (HTTP GraphQL Gateway)');
72
+ console.log('2. MCP Inspector (stdio)');
73
+ const mode = await rl.question('Select mode (1 or 2): ');
74
+
75
+ // Environment setup
76
+ const endpointString = selectedUrls.join(',');
77
+ const spawnEnv: Record<string, string> = {
78
+ ...(process.env as Record<string, string>),
79
+ ENDPOINT: endpointString
80
+ };
81
+
82
+ rl.close();
83
+
84
+ const distPath = getDistPath();
85
+ if (mode === '1') {
86
+ spawnEnv['ENABLE_HTTP'] = 'true';
87
+ console.log(`[INFO] Launching with ENDPOINT=${endpointString}`);
88
+ spawn('node', [distPath], { stdio: 'inherit', cwd: process.cwd(), env: spawnEnv });
89
+ } else {
90
+ console.log('Launching in Inspector mode...');
91
+ spawn('npx', ['-y', '@modelcontextprotocol/inspector', 'node', distPath], {
92
+ stdio: 'inherit',
93
+ cwd: process.cwd(),
94
+ env: spawnEnv
95
+ });
96
+ }
97
+ }
98
+
99
+ main().catch(err => {
100
+ console.error(err);
101
+ process.exit(1);
102
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "activeEndpoints": ["mcp", "neo4j"],
3
+ "endpoints": {
4
+ "mcp": "https://mcp-discord.vercel.app/api/graphiql",
5
+ "neo4j": "https://mcp-neo4j-discord.vercel.app/api/graphiql"
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letoribo/mcpgql",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "CLI tool for MCP GraphQL Enhanced",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -8,7 +8,8 @@
8
8
  },
9
9
  "files": [
10
10
  "index.js",
11
- "index.ts"
11
+ "core.ts",
12
+ "mcpgql.config.json"
12
13
  ],
13
14
  "scripts": {
14
15
  "test": "echo \"Error: no test specified\" && exit 1"