Skip to main content
Glama

ping_peer

Ping a specified peer device to test connectivity by sending a defined number of packets. Use the hostname or IP address for the target, enabling network diagnostics via Tailscale MCP Server.

Instructions

Ping a peer device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countYesNumber of ping packets to send
targetYesHostname or IP address of the target device

Implementation Reference

  • The handler function for the 'ping_peer' MCP tool. It takes target hostname/IP and optional count, uses the Tailscale client to perform the ping via CLI, and returns success or error.
    async function pingPeer(
      args: z.infer<typeof PingPeerSchema>,
      context: ToolContext,
    ): Promise<CallToolResult> {
      try {
        logger.debug(`Pinging ${args.target} (${args.count} packets)`);
    
        // Use unified client - this operation is CLI-only
        const result = await context.client.ping(args.target, args.count);
    
        if (!result.success) {
          return returnToolError(result.error);
        }
    
        return returnToolSuccess(
          `Ping results for ${args.target}:\n\n${result.data}`,
        );
      } catch (error: unknown) {
        logger.error("Error pinging peer:", error);
        return returnToolError(error);
      }
    }
  • Zod schema defining the input parameters for the 'ping_peer' tool: target (string) and count (number, default 4).
    const PingPeerSchema = z.object({
      target: z.string().describe("Hostname or IP address of the target device"),
      count: z
        .number()
        .int()
        .min(1)
        .max(100)
        .optional()
        .default(4)
        .describe("Number of ping packets to send"),
    });
  • Registration of the 'ping_peer' tool in the networkTools module's tools array, linking name, description, input schema, and handler function.
    {
      name: "ping_peer",
      description: "Ping a peer device",
      inputSchema: PingPeerSchema,
      handler: pingPeer,
    },

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/HexSleeves/tailscale-mcp'

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