Skip to main content
Glama
oaslananka

MCP Health Monitor

Get Uptime Statistics

get_uptime
Read-only

Retrieve uptime history and statistics for a registered MCP server by specifying its name and an optional time window from 1 to 720 hours.

Instructions

Get uptime history and statistics for a registered MCP server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesServer name
hoursNo

Implementation Reference

  • The 'get_uptime' tool registration and handler in app.ts. It registers the tool with the MCP server, fetches uptime history via getUptimeHistory(), computes average response time, p50/p95 percentiles, and returns formatted response.
    server.registerTool(
      'get_uptime',
      {
        title: 'Get Uptime Statistics',
        description: 'Get uptime history and statistics for a registered MCP server.',
        inputSchema: GetUptimeSchema,
        annotations: {
          readOnlyHint: true,
          destructiveHint: false,
          openWorldHint: false
        }
      },
      async (input: GetUptimeInput) => {
        const history = getUptimeHistory(input.name, input.hours);
        const upCount = history.filter((row) => row.status === 'up').length;
        const responseTimes = history
          .map((row) => row.response_time_ms)
          .filter((value): value is number => value !== null)
          .sort((left, right) => left - right);
        const averageResponseTime =
          responseTimes.length > 0
            ? Math.round(responseTimes.reduce((sum, value) => sum + value, 0) / responseTimes.length)
            : null;
        const p50 =
          responseTimes[Math.min(responseTimes.length - 1, Math.floor(responseTimes.length * 0.5))] ??
          null;
        const p95 =
          responseTimes[
            Math.min(responseTimes.length - 1, Math.floor(responseTimes.length * 0.95))
          ] ?? null;
    
        return formatResponse({
          name: input.name,
          period_hours: input.hours,
          total_checks: history.length,
          uptime_percent: history.length ? Math.round((upCount / history.length) * 100) : null,
          avg_response_time_ms: averageResponseTime,
          p50_response_time_ms: p50,
          p95_response_time_ms: p95,
          history: history.slice(-50)
        });
      }
  • Zod schema GetUptimeSchema defines input: name (string) and hours (number, 1-720, default 24). Also exports the inferred type GetUptimeInput.
    export const GetUptimeSchema = z.object({
      name: z.string().describe('Server name'),
      hours: z.number().int().min(1).max(720).default(24)
    });
  • src/app.ts:481-492 (registration)
    Tool registration using server.registerTool('get_uptime', ...) with title, description, inputSchema, and annotations.
    server.registerTool(
      'get_uptime',
      {
        title: 'Get Uptime Statistics',
        description: 'Get uptime history and statistics for a registered MCP server.',
        inputSchema: GetUptimeSchema,
        annotations: {
          readOnlyHint: true,
          destructiveHint: false,
          openWorldHint: false
        }
      },
  • getUptimeHistory() helper function that queries the health_checks table for records matching server name and time window, ordered by timestamp.
    export function getUptimeHistory(name: string, hours: number): HealthRecord[] {
      const since = Date.now() - hours * 60 * 60 * 1000;
      return getDb()
        .prepare(
          `
            SELECT id, server_name, timestamp, status, response_time_ms, tool_count, error_message, tools_snapshot
            FROM health_checks
            WHERE server_name = ? AND timestamp > ?
            ORDER BY timestamp ASC, id ASC
          `
        )
        .all(name, since) as HealthRecord[];
    }
  • getUptimePercent() helper used by alerts to calculate uptime percentage for a given server over a specified time window.
    export function getUptimePercent(
      db: Database.Database,
      name: string,
      hours: number
    ): number | null {
      const since = Date.now() - hours * 60 * 60 * 1000;
      const rows = db
        .prepare(
          `
            SELECT status
            FROM health_checks
            WHERE server_name = ? AND timestamp > ?
          `
        )
        .all(name, since) as Array<{ status: string }>;
    
      if (!rows.length) {
        return null;
      }
    
      const upCount = rows.filter((row) => row.status === 'up').length;
      return Math.round((upCount / rows.length) * 100);
    }
Behavior3/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false. The description adds 'history and statistics', aligning with read-only behavior, but provides no additional behavioral traits like permissions or rate limits.

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?

Single sentence, no fluff, front-loaded with verb and resource. Every word earns its place.

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?

No output schema is provided, but the description does not mention return format or statistics included. For a simple 2-param tool, it is moderately complete but could clarify output to fully compensate.

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

Parameters2/5

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

Schema description coverage is 50% (only 'name' has a schema description). The description adds no parameter semantics; it does not explain 'hours' meaning or usage beyond what the schema shows.

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

Purpose5/5

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

The description clearly states the verb 'Get' and the resource 'uptime history and statistics for a registered MCP server'. It is distinct from sibling tools like check_server (health check) and get_monitor_stats (monitoring stats).

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

Usage Guidelines3/5

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

The description does not explicitly guide when to use this tool versus alternatives like check_server or get_monitor_stats. Usage is implied by the context of 'uptime history', but no exclusions or alternative tool names are provided.

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/oaslananka/mcp-health-monitor'

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