UNPKG

it-tools-mcp

Version:

Full MCP 2025-06-18 compliant server with 121+ IT tools, logging, ping, progress tracking, cancellation, and sampling utilities

32 lines (31 loc) 1.17 kB
import { z } from "zod"; import ping from "ping"; export function registerPing(server) { server.registerTool("ping", { description: "Test network connectivity to a host. Example: ping google.com to check if it's reachable", 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", description: "Test network connectivity to a host", 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}` }] }; } }); }