-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodeDemote.ts
More file actions
23 lines (21 loc) · 773 Bytes
/
nodeDemote.ts
File metadata and controls
23 lines (21 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { z } from "zod";
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { execDocker, errorResponse } from "../utils/docker-api.js";
const inputSchema = {
nodes: z.array(z.string()).min(1).describe("Node IDs or hostnames to demote to worker"),
};
export function register(server: McpServer): void {
server.tool(
"docker_nodeDemote",
"Demote one or more Docker Swarm manager nodes to worker",
inputSchema,
async (args) => {
try {
const output = await execDocker(["node", "demote", ...args.nodes]);
return { content: [{ type: "text" as const, text: output.trim() || `Demoted nodes: ${args.nodes.join(", ")}` }] };
} catch (error) {
return errorResponse(error);
}
},
);
}