This is documentation for the next version of Grafana documentation. For the latest stable release, go to the latest version.
Observability (metrics and tracing)
The MCP server can expose Prometheus metrics and supports OpenTelemetry distributed tracing, following the OTel MCP semantic conventions.
Metrics require the SSE or streamable-http transport. Tracing uses standard OTEL_* environment variables and works independently of --metrics.
What you’ll achieve
You can scrape MCP operation metrics or export traces to Tempo or Grafana Cloud while the server runs over HTTP transports.
Before you begin
- The server running with SSE or streamable-http (metrics are not available with stdio).
Enable Prometheus metrics
When using SSE or streamable HTTP transports, enable Prometheus metrics with --metrics:
# Metrics on the main server at /metrics
./mcp-grafana -t streamable-http --metrics# Metrics on a separate listen address
./mcp-grafana -t streamable-http --metrics --metrics-address :9090Available metrics:
| Metric | Type | Description |
|---|---|---|
mcp_server_operation_duration_seconds | Histogram | MCP operation duration (labels: mcp_method_name, gen_ai_tool_name, error_type, network_transport, mcp_protocol_version) |
mcp_server_session_duration_seconds | Histogram | MCP client session duration (labels: network_transport, mcp_protocol_version) |
http_server_request_duration_seconds | Histogram | HTTP server request duration (from otelhttp) |
Note: Metrics are only available when using SSE or streamable HTTP transports. They are not available with stdio transport.
Enable OpenTelemetry tracing
When OTEL_EXPORTER_OTLP_ENDPOINT is set, the server exports traces via OTLP/gRPC.
Local example:
# Send traces to a local Tempo instance
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 \
OTEL_EXPORTER_OTLP_INSECURE=true \
./mcp-grafana -t streamable-httpGrafana Cloud example:
# Send traces to Grafana Cloud with authentication
OTEL_EXPORTER_OTLP_ENDPOINT=https://tempo-us-central1.grafana.net:443 \
OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic ..." \
./mcp-grafana -t streamable-httpTool call spans follow naming like tools/call <tool_name> and include attributes such as gen_ai.tool.name, mcp.method.name, and mcp.session.id. The server supports W3C trace context propagation from the _meta field of tool call requests.
Run with Docker (metrics and tracing)
docker run --rm -p 8000:8000 \
-e GRAFANA_URL=http://localhost:3000 \
-e GRAFANA_SERVICE_ACCOUNT_TOKEN=<your token> \
-e OTEL_EXPORTER_OTLP_ENDPOINT=http://tempo:4317 \
-e OTEL_EXPORTER_OTLP_INSECURE=true \
grafana/mcp-grafana \
-t streamable-http --metricsNext steps
Was this page helpful?
Related resources from Grafana Labs


