Skip to main content
Three metrics are recorded automatically when you call instrumentServer. They cover the lifecycle of every tool call and the process itself.

mcp.server.operation.duration

Attributes

Use cases

  • p50/p95/p99 latency per tool.
  • Error-rate alerts.
  • SLO budgets.

mcp.server.operation.count

Attributes

Use cases

  • Traffic alerts (sudden drop, sudden spike).
  • Per-tool usage breakdown.
  • Heartbeat — if this stops incrementing, the server is stuck.

mcp.server.session.duration

Attributes

Use cases

  • Track process lifetime distribution (cold starts vs long-running).
  • Alert on unexpectedly short sessions (crashes).
This is only recorded if you call telemetry.shutdown() on exit. If your process is killed without graceful shutdown, this metric won’t be emitted for that session.

What’s not (yet) automatic

These are common metrics you may want to record yourself today — see Custom instrumentation.
  • Per-tool input/output sizes.
  • Upstream API latency for tools that call external services.
  • Cache hit ratios.
  • Token / context usage when tools wrap LLM calls.

See also

Automatic attributes

Span attributes the package writes for free.

Custom instrumentation

Add your own spans, histograms, and counters.