graphjin 3.2.3 → 3.2.4
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/README.md +61 -0
- package/bin/graphjin.js +16 -0
- package/bin/install.js +116 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,6 +52,67 @@ graphjin mcp info # Copy output to Claude Desktop config
|
|
|
52
52
|
|
|
53
53
|
Within minutes, ask Claude: "What products do we have?" or "Show me orders from last week"
|
|
54
54
|
|
|
55
|
+
## Using with Claude Desktop
|
|
56
|
+
|
|
57
|
+
### Option A: Local Mode (Starts with Claude)
|
|
58
|
+
|
|
59
|
+
1. **Install GraphJin**
|
|
60
|
+
```bash
|
|
61
|
+
npm install -g graphjin
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
2. **Get the config JSON**
|
|
65
|
+
```bash
|
|
66
|
+
graphjin mcp info --path /path/to/your/config
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
3. **Add to Claude Desktop**
|
|
70
|
+
- Open Claude Desktop settings
|
|
71
|
+
- Edit `claude_desktop_config.json`
|
|
72
|
+
- Paste the JSON output
|
|
73
|
+
- Restart Claude Desktop
|
|
74
|
+
|
|
75
|
+
### Option B: Remote Mode (Always-On Server)
|
|
76
|
+
|
|
77
|
+
1. **Start GraphJin on server**
|
|
78
|
+
```bash
|
|
79
|
+
graphjin serve --path /path/to/config
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
2. **Get the proxy config** (on your local machine)
|
|
83
|
+
```bash
|
|
84
|
+
# For local server
|
|
85
|
+
graphjin mcp info --server 127.0.0.1:8080
|
|
86
|
+
|
|
87
|
+
# For remote server
|
|
88
|
+
graphjin mcp info --server 10.0.0.5:8080
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
3. **Add to Claude Desktop**
|
|
92
|
+
- Paste the JSON into `claude_desktop_config.json`
|
|
93
|
+
- Restart Claude Desktop
|
|
94
|
+
|
|
95
|
+
### Try the Webshop Demo
|
|
96
|
+
|
|
97
|
+
1. **Start the demo**
|
|
98
|
+
```bash
|
|
99
|
+
graphjin mcp demo --path examples/webshop/config
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
2. **Get config and add to Claude Desktop**
|
|
103
|
+
```bash
|
|
104
|
+
graphjin mcp demo info --path examples/webshop/config
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
3. **Ask Claude questions like:**
|
|
108
|
+
- "What tables are in the database?"
|
|
109
|
+
- "Show me all products under $50"
|
|
110
|
+
- "List customers and their purchases"
|
|
111
|
+
- "What's the total revenue by product?"
|
|
112
|
+
- "Find products with 'wireless' in the name"
|
|
113
|
+
- "Add a new product called 'USB-C Cable' for $19.99"
|
|
114
|
+
- "Which customers have returned items?"
|
|
115
|
+
|
|
55
116
|
## How It Works
|
|
56
117
|
|
|
57
118
|
1. **Connects to database** - Reads your schema automatically
|
package/bin/graphjin.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawn } = require('child_process');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const ext = process.platform === 'win32' ? '.exe' : '';
|
|
6
|
+
const binary = path.join(__dirname, 'graphjin' + ext);
|
|
7
|
+
|
|
8
|
+
const child = spawn(binary, process.argv.slice(2), { stdio: 'inherit' });
|
|
9
|
+
|
|
10
|
+
child.on('error', (err) => {
|
|
11
|
+
console.error(`Failed to start graphjin: ${err.message}`);
|
|
12
|
+
console.error('Try reinstalling: npm install -g graphjin');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
child.on('exit', (code) => process.exit(code || 0));
|
package/bin/install.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
const https = require('https');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { execSync } = require('child_process');
|
|
5
|
+
|
|
6
|
+
// Map Node.js platform/arch to Go equivalents
|
|
7
|
+
const PLATFORM_MAP = {
|
|
8
|
+
darwin: 'darwin',
|
|
9
|
+
linux: 'linux',
|
|
10
|
+
win32: 'windows',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const ARCH_MAP = {
|
|
14
|
+
x64: 'amd64',
|
|
15
|
+
arm64: 'arm64',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
async function download(url, dest) {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
const follow = (url) => {
|
|
21
|
+
https.get(url, (res) => {
|
|
22
|
+
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
23
|
+
follow(res.headers.location);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (res.statusCode !== 200) {
|
|
27
|
+
reject(new Error(`Download failed: ${res.statusCode}`));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const file = fs.createWriteStream(dest);
|
|
31
|
+
res.pipe(file);
|
|
32
|
+
file.on('finish', () => {
|
|
33
|
+
file.close();
|
|
34
|
+
resolve();
|
|
35
|
+
});
|
|
36
|
+
}).on('error', reject);
|
|
37
|
+
};
|
|
38
|
+
follow(url);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function extract(tarPath, destDir) {
|
|
43
|
+
// Use tar module for extraction
|
|
44
|
+
const tar = require('tar');
|
|
45
|
+
await tar.x({
|
|
46
|
+
file: tarPath,
|
|
47
|
+
cwd: destDir,
|
|
48
|
+
filter: (path) => path === 'graphjin' || path === 'graphjin.exe',
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function install() {
|
|
53
|
+
const pkg = require('../package.json');
|
|
54
|
+
const version = pkg.version;
|
|
55
|
+
|
|
56
|
+
const platform = PLATFORM_MAP[process.platform];
|
|
57
|
+
const arch = ARCH_MAP[process.arch];
|
|
58
|
+
|
|
59
|
+
if (!platform || !arch) {
|
|
60
|
+
console.error(`Unsupported platform: ${process.platform} ${process.arch}`);
|
|
61
|
+
console.error('Please download manually from: https://github.com/dosco/graphjin/releases');
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const ext = platform === 'windows' ? '.zip' : '.tar.gz';
|
|
66
|
+
const filename = `graphjin_${platform}_${arch}${ext}`;
|
|
67
|
+
const url = `https://github.com/dosco/graphjin/releases/download/v${version}/${filename}`;
|
|
68
|
+
|
|
69
|
+
const binDir = __dirname;
|
|
70
|
+
const archivePath = path.join(binDir, filename);
|
|
71
|
+
const binaryName = platform === 'windows' ? 'graphjin.exe' : 'graphjin';
|
|
72
|
+
const binaryPath = path.join(binDir, binaryName);
|
|
73
|
+
|
|
74
|
+
// Skip if binary already exists
|
|
75
|
+
if (fs.existsSync(binaryPath)) {
|
|
76
|
+
console.log('GraphJin binary already installed');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
console.log(`Downloading GraphJin v${version} for ${platform}/${arch}...`);
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
await download(url, archivePath);
|
|
84
|
+
|
|
85
|
+
console.log('Extracting...');
|
|
86
|
+
|
|
87
|
+
if (platform === 'windows') {
|
|
88
|
+
// For Windows, use PowerShell to extract
|
|
89
|
+
execSync(`powershell -command "Expand-Archive -Path '${archivePath}' -DestinationPath '${binDir}' -Force"`, {
|
|
90
|
+
stdio: 'inherit',
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
await extract(archivePath, binDir);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Set executable permission on Unix
|
|
97
|
+
if (platform !== 'windows') {
|
|
98
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Clean up archive
|
|
102
|
+
fs.unlinkSync(archivePath);
|
|
103
|
+
|
|
104
|
+
console.log('GraphJin installed successfully!');
|
|
105
|
+
} catch (err) {
|
|
106
|
+
console.error(`Failed to install GraphJin: ${err.message}`);
|
|
107
|
+
console.error('Please download manually from: https://github.com/dosco/graphjin/releases');
|
|
108
|
+
// Clean up on failure
|
|
109
|
+
try {
|
|
110
|
+
fs.unlinkSync(archivePath);
|
|
111
|
+
} catch {}
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
install();
|