marble-headed-mcp 0.1.6 → 0.1.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.
Files changed (2) hide show
  1. package/dist/index.js +54 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -235,7 +235,7 @@ const TOOLS = [
235
235
  },
236
236
  {
237
237
  name: 'get_container_logs',
238
- description: 'Fetch container logs for a project (requires gcloud on the headed server).',
238
+ description: 'Fetch container logs for a project and save them to a /tmp file.',
239
239
  inputSchema: {
240
240
  type: 'object',
241
241
  properties: {
@@ -315,7 +315,59 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
315
315
  }
316
316
  case 'get_container_logs': {
317
317
  const result = await postJson('/api/gcloud/read', args);
318
- return { content: [{ type: 'text', text: JSON.stringify(result.json || { status: result.status, body: result.text }, null, 2) }] };
318
+ const payload = (result.json && typeof result.json === 'object') ? result.json : null;
319
+ if (!result.ok || !payload) {
320
+ const fallbackText = result.text || '';
321
+ const filePath = path.join('/tmp', `marble-container-logs-error-${Date.now()}.log`);
322
+ await fs.writeFile(filePath, fallbackText, 'utf8');
323
+ return {
324
+ content: [
325
+ {
326
+ type: 'text',
327
+ text: JSON.stringify({
328
+ ok: false,
329
+ status: result.status,
330
+ filePath,
331
+ logsUrl: null,
332
+ }, null, 2),
333
+ },
334
+ ],
335
+ };
336
+ }
337
+ const entries = Array.isArray(payload.entries) ? payload.entries : [];
338
+ const unparsed = Array.isArray(payload.unparsed) ? payload.unparsed : [];
339
+ const lines = [];
340
+ for (const entry of entries) {
341
+ const timestamp = entry?.timestamp ? String(entry.timestamp) : '';
342
+ const text = entry?.text ? String(entry.text) : '';
343
+ if (timestamp || text) {
344
+ lines.push(`${timestamp} ${text}`.trim());
345
+ }
346
+ }
347
+ for (const line of unparsed) {
348
+ const normalized = String(line || '').trim();
349
+ if (normalized) {
350
+ lines.push(normalized);
351
+ }
352
+ }
353
+ const logText = lines.join('\n');
354
+ const projectId = payload.projectId ?? args?.projectId ?? 'unknown';
355
+ const filePath = path.join('/tmp', `marble-container-logs-${projectId}-${Date.now()}.log`);
356
+ await fs.writeFile(filePath, logText, 'utf8');
357
+ return {
358
+ content: [
359
+ {
360
+ type: 'text',
361
+ text: JSON.stringify({
362
+ ok: Boolean(payload.ok),
363
+ projectId: payload.projectId ?? args?.projectId ?? null,
364
+ count: payload.count ?? entries.length,
365
+ filePath,
366
+ logsUrl: payload.logsUrl ?? null,
367
+ }, null, 2),
368
+ },
369
+ ],
370
+ };
319
371
  }
320
372
  case 'save_image_base64': {
321
373
  const saveResult = await saveImageFromUrl({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marble-headed-mcp",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "MCP server for Marble headed automation endpoints",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",