pingHost
Check network connectivity by pinging a target host. Specify the host and number of ping requests to diagnose network availability and latency.
Instructions
Ping a host using system ping command
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | Number of ping requests | |
| host | Yes | Target host to ping |
Implementation Reference
- src/tools/network.ts:126-143 (handler)Handler function for pingHost tool that pings the specified host using the system's ping command, adjusting for Windows (-n) or Unix (-c) platforms, and returns the stdout output.handler: async ({ host, count = 4 }: { host: string; count?: number }) => { const platform = os.platform(); const pingCmd = platform === 'win32' ? `ping -n ${count} ${host}` : `ping -c ${count} ${host}`; try { const { stdout } = await execAsync(pingCmd); return { content: [{ type: 'text', text: stdout }] }; } catch (error) { throw new Error(`Ping failed: ${error instanceof Error ? error.message : 'Unknown error'}`); } }
- src/tools/network.ts:111-125 (schema)Input schema defining the parameters for the pingHost tool: required 'host' string and optional 'count' number (default 4).inputSchema: { type: 'object', properties: { host: { type: 'string', description: 'Target host to ping' }, count: { type: 'number', description: 'Number of ping requests', default: 4 } }, required: ['host'] },
- src/index.ts:28-35 (registration)Registration of all tools including networkTools (which contains pingHost) into the allTools object used for tool lookup, listing, and execution dispatching.const allTools: ToolKit = { ...systemTools, ...networkTools, ...geoTools, ...generatorTools, ...dateTimeTools, ...securityTools };