Skip to main content
Glama

health_check

Check connectivity status and latency by pinging all exchanges to verify operational readiness.

Instructions

Ping all exchanges and return connectivity status and latency

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The function `runHealthCheck` handles the execution of health checks across multiple exchanges (pacifica, hyperliquid, lighter) and prints the status or returns it as JSON.
    export async function runHealthCheck(isJson: () => boolean): Promise<void> {
          const [pacPing, hlPing, ltPing] = await Promise.all([
            pingPacifica(),
            pingHyperliquid(),
            pingLighter(),
          ]);
          const toPingResult = (name: string, p: { ok: boolean; latencyMs: number; status: number }): HealthResult => ({
            exchange: name,
            status: p.ok ? "ok" : "down",
            latency_ms: p.latencyMs,
            error: p.ok ? undefined : `HTTP ${p.status}`,
          });
          const checks: HealthResult[] = [
            toPingResult("pacifica", pacPing),
            toPingResult("hyperliquid", hlPing),
            toPingResult("lighter", ltPing),
          ];
    
          const allOk = checks.every(c => c.status === "ok");
    
          if (isJson()) {
            return printJson(jsonOk({ healthy: allOk, exchanges: checks }));
          }
    
          console.log(chalk.cyan.bold("\n  Exchange Health Check\n"));
          const rows = checks.map(c => {
            const statusIcon = c.status === "ok"
              ? chalk.green("OK")
              : c.status === "degraded"
              ? chalk.yellow("DEGRADED")
              : chalk.red("DOWN");
            const latency = c.latency_ms < 500
              ? chalk.green(`${c.latency_ms}ms`)
              : c.latency_ms < 2000
              ? chalk.yellow(`${c.latency_ms}ms`)
              : chalk.red(`${c.latency_ms}ms`);
            return [
              chalk.white.bold(c.exchange),
              statusIcon,
              latency,
              c.error ? chalk.red(c.error) : chalk.gray("-"),
            ];
          });
    
          console.log(makeTable(["Exchange", "Status", "Latency", "Error"], rows));
    
          const overall = allOk ? chalk.green("ALL HEALTHY") : chalk.red("ISSUES DETECTED");
          console.log(`\n  Overall: ${overall}\n`);
    }

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/hypurrquant/perp-cli'

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