@moor-sh/mcp 0.13.0 → 0.14.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/package.json +1 -1
- package/src/index.ts +39 -6
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -320,7 +320,8 @@ server.registerTool(
|
|
|
320
320
|
"moor_logs",
|
|
321
321
|
{
|
|
322
322
|
title: "Get Container Logs",
|
|
323
|
-
description:
|
|
323
|
+
description:
|
|
324
|
+
"Get recent logs from a project's container. Annotates output with state: ok (container running), exited (container is stopped but Docker still has logs), no_container (project never started), or missing (container_id is set but Docker doesn't have it). Throws only on docker_error (Docker daemon 5xx / unreachable) so an operator can distinguish infrastructure failure from app silence — pre-#74 the tool returned empty logs for all of these.",
|
|
324
325
|
inputSchema: z.object({
|
|
325
326
|
project: z.string().describe("Project name or ID"),
|
|
326
327
|
lines: z.number().optional().default(100).describe("Number of log lines to retrieve"),
|
|
@@ -329,11 +330,43 @@ server.registerTool(
|
|
|
329
330
|
async ({ project, lines }) => {
|
|
330
331
|
const p = await resolveProject(project);
|
|
331
332
|
const res = await apiGet(`/api/projects/${p.id}/logs?tail=${lines}`);
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
333
|
+
// 502 = API surfaced a Docker daemon failure. Throw so the agent
|
|
334
|
+
// gets a tool error, not silent empty logs.
|
|
335
|
+
if (res.status === 502) {
|
|
336
|
+
const data = (await res.json().catch(() => ({}))) as { error?: string };
|
|
337
|
+
throw new Error(`Docker error: ${data.error ?? "unknown"}`);
|
|
338
|
+
}
|
|
339
|
+
if (!res.ok) throw new Error(`Failed: ${res.status} ${await res.text()}`);
|
|
340
|
+
const data = (await res.json()) as { logs: string; state?: string };
|
|
341
|
+
switch (data.state) {
|
|
342
|
+
case "no_container":
|
|
343
|
+
return {
|
|
344
|
+
content: [{ type: "text", text: "(project hasn't been started yet — no container)" }],
|
|
345
|
+
};
|
|
346
|
+
case "missing":
|
|
347
|
+
return {
|
|
348
|
+
content: [
|
|
349
|
+
{
|
|
350
|
+
type: "text",
|
|
351
|
+
text: "(container_id was recorded but Docker doesn't have it; moor may need to recreate the project)",
|
|
352
|
+
},
|
|
353
|
+
],
|
|
354
|
+
};
|
|
355
|
+
case "exited":
|
|
356
|
+
return {
|
|
357
|
+
content: [
|
|
358
|
+
{
|
|
359
|
+
type: "text",
|
|
360
|
+
text: `${data.logs || "(no logs captured)"}\n\n(container is exited; logs above are from before)`,
|
|
361
|
+
},
|
|
362
|
+
],
|
|
363
|
+
};
|
|
364
|
+
default:
|
|
365
|
+
// "ok" or undefined (older API) — render raw.
|
|
366
|
+
return {
|
|
367
|
+
content: [{ type: "text", text: data.logs || "(no logs)" }],
|
|
368
|
+
};
|
|
369
|
+
}
|
|
337
370
|
},
|
|
338
371
|
);
|
|
339
372
|
|