it-tools-mcp
Version:
MCP-compliant server access to over 100 IT tools and utilities commonly used by developers, system administrators, and IT professionals.
30 lines (29 loc) • 990 B
JavaScript
import { z } from "zod";
import ping from "ping";
export function registerPing(server) {
server.registerTool("ping", {
inputSchema: {
target: z.string().describe("Host to ping"),
count: z.number().default(4).describe("Number of ping attempts")
},
// VS Code compliance annotations
annotations: {
title: "Ping",
readOnlyHint: false
}
}, async ({ target, count }) => {
try {
const res = await ping.promise.probe(target, { min_reply: count });
return {
content: [
{ type: "text", text: `Ping to ${target}:\nAlive: ${res.alive}\nTime: ${res.time} ms\nOutput: ${res.output}` }
]
};
}
catch (error) {
return {
isError: true, content: [{ type: "text", text: `Ping failed: ${error instanceof Error ? error.message : error}` }]
};
}
});
}