Skip to main content
Glama

metrics-snapshot

Read in-memory golden-signals metrics for this MCP server: counters and latency p50, p95, p99 per tool.

Instructions

Read in-memory golden-signals metrics for this MCP server (counters + latency p50/p95/p99 per tool).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'metrics-snapshot' tool. Calls metricsSnapshot() to get in-memory golden signals, then conditionally persists to disk (throttled to 1s via AUTO_PERSIST_THROTTLE_MS). Returns the snapshot payload.
    async function handleMetricsSnapshot() {
      const payload = metricsSnapshot();
      const now = Date.now();
      if (now - _lastAutoPersistTs >= AUTO_PERSIST_THROTTLE_MS) {
        try {
          await persistSnapshot();
          _lastAutoPersistTs = now;
        } catch (err) {
          // OBS-20-01: graceful — log to stderr, do NOT fail the handler.
          // In-memory snapshot still returned normally so the client tool call
          // contract is preserved even when fs is read-only or quota-exhausted.
          process.stderr.write(`[kit-mcp] auto-snapshot persist failed: ${err.message}\n`);
        }
      }
      return payload;
    }
  • Tool registration map: maps the string 'metrics-snapshot' to handleMetricsSnapshot.
    const HANDLERS = {
      kit:                handleKit,
      sync:               handleSync,
      'reverse-sync':     handleReverseSync,
      gates:              handleGates,
      forensics:          handleForensics,
      install:            handleInstall,
      'metrics-snapshot': handleMetricsSnapshot,
      'auto-install':     handleAutoInstall,
      'ack-restart':      handleAckRestart,
    };
  • Schema definition for 'metrics-snapshot' tool: parameterless (empty input schema), returns counters and latency p50/p95/p99 per tool.
      // OBS-18 (Phase 94.01): expose four-golden-signals data for the MCP server itself.
      // Read-only (no auth needed beyond the underlying transport): returns counters
      // keyed `${tool}:${status}` and per-tool latency p50/p95/p99/count.
      name: 'metrics-snapshot',
      description: 'Read in-memory golden-signals metrics for this MCP server (counters + latency p50/p95/p99 per tool).',
      inputSchema: {
        type: 'object',
        properties: {},
      },
    },
  • The snapshot() function that builds the read-only metrics payload: counters (keyed tool:status) and per-tool latency p50/p95/p99/count from in-memory histograms.
    export function snapshot() {
      const out = { counters: {}, latency: {} };
      for (const [key, val] of counters) out.counters[key] = val;
      for (const [tool, samples] of histograms) {
        if (samples.length === 0) continue;
        const sorted = [...samples].sort((a, b) => a - b);
        out.latency[tool] = {
          p50: percentile(sorted, 0.50),
          p95: percentile(sorted, 0.95),
          p99: percentile(sorted, 0.99),
          count: samples.length,
        };
      }
      return out;
    }
  • Persists the current snapshot to disk under .planning/metrics/snapshots/ with rolling 30-day cleanup. Called via throttle from handleMetricsSnapshot.
    export async function persistSnapshot(rootDir = process.cwd(), opts = {}) {
      const retentionMs = Number.isFinite(opts.retentionMs) ? opts.retentionMs : DEFAULT_RETENTION_MS;
      const dir = path.join(rootDir, SNAPSHOT_DIR_REL);
      await fs.mkdir(dir, { recursive: true });
      const ts = Date.now();
      const snap = { ts, ...snapshot() };
      // Filesystem-safe ISO encoding — Windows forbids `:` in paths and `.` is
      // ambiguous with extension separators on shells with brace expansion.
      const isoSafe = new Date(ts).toISOString().replace(/[:.]/g, '-');
      const file = path.join(dir, `${isoSafe}.json`);
      await fs.writeFile(file, JSON.stringify(snap, null, 2));
      await cleanupOldSnapshots(dir, retentionMs);
      return { file, snap };
    }
Behavior4/5

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

No annotations are provided, so the description carries the full burden. It clearly indicates a read operation and specifies the data is in-memory, implying no side effects, though it could mention if there are rate limits or performance impacts.

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 with no redundant information. The action and content are front-loaded.

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

Completeness5/5

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

Given no parameters and no output schema, the description adequately covers what the tool returns (counters and latency percentiles per tool). No additional information is needed.

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

Parameters4/5

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

There are no parameters, so the baseline is 4. The description does not need to add parameter details.

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 tool reads in-memory golden-signals metrics and specifies what metrics are included (counters + latency p50/p95/p99 per tool), differentiating it from action-oriented sibling tools like 'ack-restart' or 'sync'.

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 implies the tool is for retrieving metrics but does not provide explicit guidance on when to use it versus alternatives or when not to use it.

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/luanpdd/kit-mcp'

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