server.ts
Run
What this demonstrates
Auto span on every call
Each call to
calculate-bmi produces a tools/call calculate-bmi span
with full attribute set.Error attributes
The
RangeError on bad input sets error.type, error.message, and
mcp.operation.success: false.Auto metrics
mcp.server.operation.duration and mcp.server.operation.count
record automatically.Graceful shutdown
SIGINT / SIGTERM trigger
telemetry.shutdown() so the final metric
batch flushes.Trying error attribution
SendheightM: 0 and you’ll see a span with status ERROR and these
attributes:
mcp.operation.success: false,
which is what you want for error-rate alerts.