Skip to main content
Glama

ping

Read-only

Test network connectivity by sending ICMP echo requests to a specified host and receiving response data.

Instructions

Pings a host and returns the result

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostYesThe hostname or URL to ping (e.g., 'google.com' or 'https://google.com')

Implementation Reference

  • The execute handler for the "ping" tool which runs a platform-specific ping command.
    execute: async (args) => {
      try {
        // Extract hostname from URL if needed
        let hostname = args.host;
    
        // If it's a full URL, extract the hostname
        if (hostname.startsWith("http://") || hostname.startsWith("https://")) {
          const url = new URL(hostname);
          hostname = url.hostname;
        }
    
        // Execute ping command (platform-specific)
        const isWindows = process.platform === "win32";
        const pingCommand = isWindows
          ? `ping -n 4 ${hostname}`
          : `ping -c 4 ${hostname}`;
    
        const { stderr, stdout } = await execAsync(pingCommand);
    
        if (stderr) {
          return `Failed to ping ${hostname}:\n${stderr}`;
        }
    
        return `Ping results for ${hostname}:\n\n${stdout}`;
      } catch (error) {
        const errorMessage =
          error instanceof Error ? error.message : "Unknown error occurred";
        return `Failed to ping ${args.host}:\n${errorMessage}`;
      }
    },
  • Registration of the "ping" tool using the FastMCP server instance.
    server.addTool({
      annotations: {
        openWorldHint: false,
        readOnlyHint: true,
        title: "Ping",
      },
      description: "Pings a host and returns the result",
      execute: async (args) => {
        try {
          // Extract hostname from URL if needed
          let hostname = args.host;
    
          // If it's a full URL, extract the hostname
          if (hostname.startsWith("http://") || hostname.startsWith("https://")) {
            const url = new URL(hostname);
            hostname = url.hostname;
          }
    
          // Execute ping command (platform-specific)
          const isWindows = process.platform === "win32";
          const pingCommand = isWindows
            ? `ping -n 4 ${hostname}`
            : `ping -c 4 ${hostname}`;
    
          const { stderr, stdout } = await execAsync(pingCommand);
    
          if (stderr) {
            return `Failed to ping ${hostname}:\n${stderr}`;
          }
    
          return `Ping results for ${hostname}:\n\n${stdout}`;
        } catch (error) {
          const errorMessage =
            error instanceof Error ? error.message : "Unknown error occurred";
          return `Failed to ping ${args.host}:\n${errorMessage}`;
        }
      },
      name: "ping",
      parameters: z.object({
        host: z
          .string()
          .describe(
            "The hostname or URL to ping (e.g., 'google.com' or 'https://google.com')",
          ),
      }),
    });
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations provide readOnlyHint=true and openWorldHint=false, indicating a safe, read-only operation with deterministic behavior. The description adds minimal context beyond this, stating it 'returns the result' but not detailing format, latency, error handling, or network-specific traits. It doesn't contradict annotations, but offers limited behavioral insight, relying heavily on structured data.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise—a single sentence that directly states the tool's action and outcome without unnecessary words. It is front-loaded with the core purpose, making it efficient and easy to parse, with every part earning its place by conveying essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (one parameter, simple operation) and annotations covering safety and determinism, the description is minimally adequate. However, without an output schema, it lacks details on return values (e.g., success/failure indicators, latency metrics). The description provides basic context but misses opportunities to clarify behavioral aspects like timeouts or error responses.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the 'host' parameter fully documented in the schema. The description does not add any meaning beyond the schema, such as examples of valid hosts or ping behavior specifics. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but doesn't detract either.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Pings') and resource ('a host'), and specifies the outcome ('returns the result'). It distinguishes itself from potential alternatives by focusing on network connectivity testing. However, with no sibling tools listed, the differentiation is implicit rather than explicit against specific alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or contextual constraints. It mentions the action and result but lacks explicit usage scenarios, exclusions, or comparisons to other tools, leaving the agent to infer appropriate contexts independently.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/punkpeye/mcp-ping'

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