-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodeList.ts
More file actions
32 lines (28 loc) · 878 Bytes
/
Copy pathnodeList.ts
File metadata and controls
32 lines (28 loc) · 878 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
28
29
30
31
32
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { execSSH, listNodes } from "../utils/ssh-api.js";
const inputSchema = {};
export function register(server: McpServer): void {
server.tool(
"homelab_nodeList",
"List all managed nodes and their connection status",
inputSchema,
async () => {
const nodes = listNodes();
const results: string[] = [];
for (const node of nodes) {
try {
await execSSH("echo ok", node.name === "default" ? undefined : node.name);
results.push(`${node.name} (${node.host}) -- online`);
} catch {
results.push(`${node.name} (${node.host}) -- offline`);
}
}
return {
content: [{
type: "text" as const,
text: results.join("\n") || "No nodes configured.",
}],
};
},
);
}