Skip to main content
Glama

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
NameRequiredDescriptionDefault
hostYesTarget host to ping
countNoNumber of ping requests

Implementation Reference

  • 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'}`);
      }
    }
  • 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';
  • 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') {

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cyanheads/toolkit-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server