Skip to main content
Glama

pot_health

Monitor Proof of Time system health by checking time source status, subgraph synchronization, server uptime, and operational mode.

Instructions

Check PoT system health: time source status, subgraph sync, server uptime, and current mode.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function 'potHealth' that checks the health of time synthesis sources, subgraph indexing status, and general server metrics.
    export async function potHealth(): Promise<unknown> {
      telemetryIncrement("pot_health");
    
      let timeStatus = "unknown";
      let synthSources = 0;
      try {
        const synth = await Promise.race([
          timeSynth.synthesize(),
          new Promise<null>((_, reject) =>
            setTimeout(() => reject(new Error("timeout")), 5000)
          ),
        ]);
        if (synth && synth.sources >= 2) {
          timeStatus = "healthy";
          synthSources = synth.sources;
        } else {
          timeStatus = "degraded";
          synthSources = synth?.sources ?? 0;
        }
      } catch {
        timeStatus = "unhealthy";
      }
    
      let latestBlock = 0;
      let syncStatus = "unknown";
      try {
        const query = `{ _meta { block { number } hasIndexingErrors } }`;
        const controller = new AbortController();
        const timeout = setTimeout(() => controller.abort(), 5000);
        const resp = await fetch(SUBGRAPH_URL, {
          method: "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify({ query }),
          signal: controller.signal,
        });
        clearTimeout(timeout);
    
        if (resp.ok) {
          const json = (await resp.json()) as {
            data?: { _meta?: { block?: { number: number }; hasIndexingErrors?: boolean } };
          };
          latestBlock = json.data?._meta?.block?.number ?? 0;
          syncStatus = json.data?._meta?.hasIndexingErrors ? "indexing_errors" : "synced";
        }
      } catch {
        syncStatus = "unreachable";
      }
    
      const uptimeMs = Date.now() - startedAt;
    
      return serialize({
        status: timeStatus === "healthy" ? "ok" : timeStatus,
        timeSources: { status: timeStatus, activeSources: synthSources },
        subgraph: { latestBlock, syncStatus },
        server: {
          uptime: uptimeMs,
          uptimeHuman: `${(uptimeMs / 3600000).toFixed(1)}h`,
          potCount: potLog.length,
          currentMode: adaptiveSwitch.getCurrentMode(),
          signerPubKey: potSigner.getPubKeyHex(),
        },
      });
    }

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/Helm-Protocol/openttt-mcp'

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