> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sedata-ai.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# Automatic metrics

> Metrics the package records without any code from you.

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`

| Type        | Histogram                                                                                                                       |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------- |
| Unit        | `ms`                                                                                                                            |
| Description | MCP request or notification duration as observed on the receiver from the time it was received until the result or ack is sent. |
| Recorded    | Once per tool invocation.                                                                                                       |

### Attributes

| Attribute               | Always present  | Description                      |
| ----------------------- | --------------- | -------------------------------- |
| `mcp.method.name`       | ✅               | Always `"tools/call"` for tools. |
| `mcp.tool.name`         | ✅               | Tool name.                       |
| `mcp.session.id`        | ✅               | Process-stable UUID.             |
| `mcp.operation.success` | ✅               | `true`/`false`.                  |
| `error.type`            | only on failure | Error class name.                |

### Use cases

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

## `mcp.server.operation.count`

| Type        | Counter                                                        |
| ----------- | -------------------------------------------------------------- |
| Unit        | `calls`                                                        |
| Description | MCP request or notification count as observed on the receiver. |
| Incremented | Once per tool invocation, before the handler runs.             |

### Attributes

| Attribute         | Description     |
| ----------------- | --------------- |
| `mcp.method.name` | `"tools/call"`. |
| `mcp.tool.name`   | Tool name.      |
| `mcp.session.id`  | Process UUID.   |

### 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`

| Type        | Histogram                                                                                                          |
| ----------- | ------------------------------------------------------------------------------------------------------------------ |
| Unit        | `s`                                                                                                                |
| Description | MCP server session duration as observed on the receiver from the time it was received until the session is closed. |
| Recorded    | Once when `telemetry.shutdown()` runs.                                                                             |

### Attributes

| Attribute        | Description                    |
| ---------------- | ------------------------------ |
| `mcp.session.id` | The process UUID being closed. |

### Use cases

* Track process lifetime distribution (cold starts vs long-running).
* Alert on unexpectedly short sessions (crashes).

<Warning>
  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.
</Warning>

## What's not (yet) automatic

These are common metrics you may want to record yourself today — see
[Custom instrumentation](/metrics-and-traces/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

<CardGroup cols={2}>
  <Card title="Automatic attributes" icon="list" href="/metrics-and-traces/automatic-attributes">
    Span attributes the package writes for free.
  </Card>

  <Card title="Custom instrumentation" icon="code" href="/metrics-and-traces/custom-instrumentation">
    Add your own spans, histograms, and counters.
  </Card>
</CardGroup>
