reportdash-datastore-mcp-claude-desktop 1.0.5 → 1.0.7
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/index.js +33 -12
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
//goto folder, increment version then run > npm publish --access public
|
|
2
3
|
|
|
3
4
|
const https = require('https');
|
|
4
5
|
const http = require('http');
|
|
@@ -21,6 +22,18 @@ if (!API_KEY) {
|
|
|
21
22
|
process.exit(1);
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Ensure every outbound request includes platform="claude"
|
|
27
|
+
* without breaking existing requests.
|
|
28
|
+
*/
|
|
29
|
+
function withClaudePlatform(mcpRequest) {
|
|
30
|
+
// If caller already provided platform, keep it.
|
|
31
|
+
if (mcpRequest && typeof mcpRequest === 'object') {
|
|
32
|
+
if (!mcpRequest.platform) mcpRequest.platform = 'claude';
|
|
33
|
+
}
|
|
34
|
+
return mcpRequest;
|
|
35
|
+
}
|
|
36
|
+
|
|
24
37
|
// Test mode
|
|
25
38
|
if (process.argv.includes('--test')) {
|
|
26
39
|
testConnection();
|
|
@@ -39,9 +52,10 @@ rl.on('line', (line) => {
|
|
|
39
52
|
|
|
40
53
|
try {
|
|
41
54
|
const mcpRequest = JSON.parse(line);
|
|
42
|
-
forwardToAPI(mcpRequest);
|
|
55
|
+
forwardToAPI(withClaudePlatform(mcpRequest));
|
|
43
56
|
} catch (error) {
|
|
44
|
-
|
|
57
|
+
// Only output to stdout, never stderr for MCP protocol
|
|
58
|
+
console.log(JSON.stringify({
|
|
45
59
|
jsonrpc: '2.0',
|
|
46
60
|
error: {
|
|
47
61
|
code: -32700,
|
|
@@ -78,9 +92,9 @@ function forwardToAPI(mcpRequest) {
|
|
|
78
92
|
});
|
|
79
93
|
|
|
80
94
|
res.on('end', () => {
|
|
81
|
-
// Treat 200-299 as success
|
|
95
|
+
// Treat 200-299 as success (including 204 No Content)
|
|
82
96
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
83
|
-
// For 204 No Content, return empty success
|
|
97
|
+
// For 204 No Content or empty response, return empty success
|
|
84
98
|
if (res.statusCode === 204 || !data.trim()) {
|
|
85
99
|
console.log(JSON.stringify({
|
|
86
100
|
jsonrpc: '2.0',
|
|
@@ -88,10 +102,12 @@ function forwardToAPI(mcpRequest) {
|
|
|
88
102
|
id: mcpRequest.id || null
|
|
89
103
|
}));
|
|
90
104
|
} else {
|
|
105
|
+
// Forward the response as-is
|
|
91
106
|
console.log(data);
|
|
92
107
|
}
|
|
93
108
|
} else {
|
|
94
|
-
|
|
109
|
+
// Send errors to stdout (not stderr!) so Claude can properly handle them
|
|
110
|
+
console.log(JSON.stringify({
|
|
95
111
|
jsonrpc: '2.0',
|
|
96
112
|
error: {
|
|
97
113
|
code: res.statusCode,
|
|
@@ -105,7 +121,8 @@ function forwardToAPI(mcpRequest) {
|
|
|
105
121
|
});
|
|
106
122
|
|
|
107
123
|
req.on('error', (error) => {
|
|
108
|
-
|
|
124
|
+
// Send errors to stdout (not stderr!)
|
|
125
|
+
console.log(JSON.stringify({
|
|
109
126
|
jsonrpc: '2.0',
|
|
110
127
|
error: {
|
|
111
128
|
code: -32603,
|
|
@@ -118,7 +135,8 @@ function forwardToAPI(mcpRequest) {
|
|
|
118
135
|
|
|
119
136
|
req.on('timeout', () => {
|
|
120
137
|
req.destroy();
|
|
121
|
-
|
|
138
|
+
// Send errors to stdout (not stderr!)
|
|
139
|
+
console.log(JSON.stringify({
|
|
122
140
|
jsonrpc: '2.0',
|
|
123
141
|
error: {
|
|
124
142
|
code: -32603,
|
|
@@ -142,11 +160,11 @@ function testConnection() {
|
|
|
142
160
|
const client = isHttps ? https : http;
|
|
143
161
|
|
|
144
162
|
// Create MCP tools/list request
|
|
145
|
-
const mcpRequest = {
|
|
163
|
+
const mcpRequest = withClaudePlatform({
|
|
146
164
|
jsonrpc: '2.0',
|
|
147
165
|
method: 'tools/list',
|
|
148
166
|
id: 'test-connection'
|
|
149
|
-
};
|
|
167
|
+
});
|
|
150
168
|
|
|
151
169
|
const postData = JSON.stringify(mcpRequest);
|
|
152
170
|
|
|
@@ -176,7 +194,7 @@ function testConnection() {
|
|
|
176
194
|
if (res.statusCode === 204 || !data.trim()) {
|
|
177
195
|
console.log('✅ Connection successful!');
|
|
178
196
|
console.log('✅ API key is valid');
|
|
179
|
-
console.log('ℹ️ Server returned 204 No Content
|
|
197
|
+
console.log('ℹ️ Server returned 204 No Content\n');
|
|
180
198
|
} else {
|
|
181
199
|
try {
|
|
182
200
|
const response = JSON.parse(data);
|
|
@@ -185,10 +203,13 @@ function testConnection() {
|
|
|
185
203
|
|
|
186
204
|
if (response.result && response.result.tools) {
|
|
187
205
|
console.log(`📦 Available Tools: ${response.result.tools.length}\n`);
|
|
188
|
-
response.result.tools.forEach((tool, index) => {
|
|
206
|
+
response.result.tools.slice(0, 5).forEach((tool, index) => {
|
|
189
207
|
console.log(`${index + 1}. ${tool.name}`);
|
|
190
208
|
console.log(` ${tool.description}\n`);
|
|
191
209
|
});
|
|
210
|
+
if (response.result.tools.length > 5) {
|
|
211
|
+
console.log(`... and ${response.result.tools.length - 5} more tools`);
|
|
212
|
+
}
|
|
192
213
|
} else {
|
|
193
214
|
console.log('Response:', JSON.stringify(response, null, 2));
|
|
194
215
|
}
|
|
@@ -222,4 +243,4 @@ function testConnection() {
|
|
|
222
243
|
|
|
223
244
|
req.write(postData);
|
|
224
245
|
req.end();
|
|
225
|
-
}
|
|
246
|
+
}
|