pingHost
Check network connectivity by sending ping requests to a target host and measuring response times.
Instructions
Ping a host using system ping command
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| host | Yes | Target host to ping | |
| count | No | Number of ping requests |
Implementation Reference
- src/tools/network.ts:126-143 (handler)The handler function for the pingHost tool. It constructs a platform-specific ping command (Windows: ping -n, Unix: ping -c), executes it using execAsync, and returns the stdout output or throws an error.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 definition for the pingHost tool, requiring a 'host' string and optionally a 'count' number.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)The allTools object spreads networkTools (which includes pingHost) to register it for tool lookup and execution.const allTools: ToolKit = { ...systemTools, ...networkTools, ...geoTools, ...generatorTools, ...dateTimeTools, ...securityTools };
- src/index.ts:6-6 (registration)Imports the networkTools object containing the pingHost tool definition.import { networkTools } from './tools/network.js';
- src/index.ts:145-147 (helper)Rate limiter selection references 'ping_host' (note: tool name is 'pingHost'), applying networkRateLimiter.} else if (request.params.name.startsWith('get_network') || request.params.name === 'ping_host' || request.params.name === 'traceroute') {