-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodePromote.ts
More file actions
23 lines (21 loc) · 779 Bytes
/
nodePromote.ts
File metadata and controls
23 lines (21 loc) · 779 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 promote to manager"),
};
export function register(server: McpServer): void {
server.tool(
"docker_nodePromote",
"Promote one or more Docker Swarm worker nodes to manager",
inputSchema,
async (args) => {
try {
const output = await execDocker(["node", "promote", ...args.nodes]);
return { content: [{ type: "text" as const, text: output.trim() || `Promoted nodes: ${args.nodes.join(", ")}` }] };
} catch (error) {
return errorResponse(error);
}
},
);
}