@aithr-ai/mcp-server 1.0.4 → 1.0.5
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 +29 -65
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1213,77 +1213,41 @@ class MCPServer {
|
|
|
1213
1213
|
return { error: 'No project ID configured. Set AETHER_PROJECT_ID environment variable.' };
|
|
1214
1214
|
}
|
|
1215
1215
|
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
const headers = {
|
|
1220
|
-
'Content-Type': 'application/json',
|
|
1221
|
-
};
|
|
1222
|
-
|
|
1223
|
-
if (config.apiKey) {
|
|
1224
|
-
headers['Authorization'] = `Bearer ${config.apiKey}`;
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
const response = await fetch(url, {
|
|
1228
|
-
method: 'POST',
|
|
1229
|
-
headers,
|
|
1230
|
-
body: JSON.stringify({ context }),
|
|
1231
|
-
});
|
|
1232
|
-
|
|
1233
|
-
if (!response.ok) {
|
|
1234
|
-
const errorText = await response.text();
|
|
1235
|
-
throw new Error(`API error: ${response.status} - ${errorText}`);
|
|
1236
|
-
}
|
|
1216
|
+
if (!nodeId) {
|
|
1217
|
+
return { error: 'nodeId is required' };
|
|
1218
|
+
}
|
|
1237
1219
|
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
while (true) {
|
|
1248
|
-
const { done, value } = await reader.read();
|
|
1249
|
-
if (done) break;
|
|
1250
|
-
|
|
1251
|
-
buffer += decoder.decode(value, { stream: true });
|
|
1252
|
-
|
|
1253
|
-
// Parse SSE events from buffer
|
|
1254
|
-
const lines = buffer.split('\n');
|
|
1255
|
-
buffer = lines.pop() || ''; // Keep incomplete line in buffer
|
|
1256
|
-
|
|
1257
|
-
for (const line of lines) {
|
|
1258
|
-
if (line.startsWith('event: ')) {
|
|
1259
|
-
lastEvent = line.slice(7).trim();
|
|
1260
|
-
} else if (line.startsWith('data: ')) {
|
|
1261
|
-
try {
|
|
1262
|
-
const data = JSON.parse(line.slice(6));
|
|
1263
|
-
|
|
1264
|
-
if (lastEvent === 'generation_complete') {
|
|
1265
|
-
artifactId = data.artifactId;
|
|
1266
|
-
sessionId = data.sessionId;
|
|
1267
|
-
} else if (lastEvent === 'error') {
|
|
1268
|
-
error = data.error || 'Generation failed';
|
|
1269
|
-
}
|
|
1270
|
-
} catch {
|
|
1271
|
-
// Ignore JSON parse errors for partial data
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1220
|
+
try {
|
|
1221
|
+
// Use MCP endpoint with API key auth (non-streaming, waits for completion)
|
|
1222
|
+
const result = await this.mcpApiCall(
|
|
1223
|
+
`/mcp/projects/${projectId}/generate`,
|
|
1224
|
+
'POST',
|
|
1225
|
+
{
|
|
1226
|
+
nodeId,
|
|
1227
|
+
context: context || undefined,
|
|
1228
|
+
previewLength: 500,
|
|
1274
1229
|
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
if (error) {
|
|
1278
|
-
return { success: false, error };
|
|
1279
|
-
}
|
|
1230
|
+
);
|
|
1280
1231
|
|
|
1281
1232
|
return {
|
|
1282
1233
|
success: true,
|
|
1283
1234
|
message: 'Generation completed',
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1235
|
+
node: result.node,
|
|
1236
|
+
generation: {
|
|
1237
|
+
status: result.generation?.status,
|
|
1238
|
+
preview: result.generation?.preview,
|
|
1239
|
+
hasMore: result.generation?.hasMore,
|
|
1240
|
+
duration: result.generation?.duration,
|
|
1241
|
+
},
|
|
1242
|
+
artifact: result.artifact
|
|
1243
|
+
? {
|
|
1244
|
+
id: result.artifact.id,
|
|
1245
|
+
title: result.artifact.title,
|
|
1246
|
+
type: result.artifact.type,
|
|
1247
|
+
}
|
|
1248
|
+
: null,
|
|
1249
|
+
usage: result.usage,
|
|
1250
|
+
hint: result.artifact?.id
|
|
1287
1251
|
? 'Use aether_extract_files to extract code from the artifact, then aether_push_artifacts to push to GitHub.'
|
|
1288
1252
|
: undefined,
|
|
1289
1253
|
};
|