-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodeInspect.ts
More file actions
27 lines (25 loc) · 888 Bytes
/
nodeInspect.ts
File metadata and controls
27 lines (25 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { z } from "zod";
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { execDocker, errorResponse } from "../utils/docker-api.js";
const inputSchema = {
node: z.string().min(1).describe("Node ID or hostname"),
pretty: z.boolean().optional().default(false).describe("Print in human-readable format"),
};
export function register(server: McpServer): void {
server.tool(
"docker_nodeInspect",
"Display detailed information on a Docker Swarm node",
inputSchema,
async (args) => {
try {
const cmdArgs = ["node", "inspect"];
if (args.pretty) cmdArgs.push("--pretty");
cmdArgs.push(args.node);
const output = await execDocker(cmdArgs);
return { content: [{ type: "text" as const, text: output.trim() }] };
} catch (error) {
return errorResponse(error);
}
},
);
}