MCP Logging and Observability

What MCP provides today and what's missing for full-stack observability

This document covers how the Model Context Protocol (MCP) supports logging and observability, including its notification system, and provides context on OpenTelemetry as the broader observability standard.

← Back to AI Tools Integration

01 / MCP LOGGING

MCP Logging Primitive

MCP includes a built-in Logging utility primitive that enables servers to send structured log messages to clients for debugging and monitoring purposes.

Capability Declaration

Servers that emit log messages must declare the logging capability during initialization:

{
  "capabilities": {
    "logging": {}
  }
}

Log Levels

MCP logging uses severity levels aligned with RFC-5424 syslog conventions:

LevelDescription
debugDetailed debugging information
infoInformational messages
noticeNormal but significant conditions
warningWarning conditions
errorError conditions
criticalCritical conditions
alertAction must be taken immediately
emergencySystem is unusable

Protocol Flow

  1. Client sets verbosity: Client sends logging/setLevel request specifying the minimum log level (e.g., info)
  2. Server acknowledges: Server responds with an empty result confirming the level
  3. Server emits logs: Server sends notifications/message containing logs at or above the configured level
  4. Dynamic adjustment: Client can issue another logging/setLevel to change verbosity at any time

Log Message Structure

{
  "jsonrpc": "2.0",
  "method": "notifications/message",
  "params": {
    "level": "error",
    "logger": "router",
    "data": {
      "error_code": 500,
      "details": "Internal Server Error"
    }
  }
}

Fields:

Important: STDIO Transport Caveat

When running MCP servers over STDIO transport, avoid writing logs directly to stdout/stderr as this can disrupt the MCP protocol stream. MCP itself relies on STDIO for structured communication, so mixing logs with protocol messages can cause parsing errors or disconnections.

02 / NOTIFICATIONS

MCP Notifications

Notifications are a core messaging primitive in MCP, built on JSON-RPC 2.0. Unlike requests, notifications are one-way messages that do not expect a response.

Notification Types

MCP uses notifications for several purposes:

NotificationPurpose
notifications/messageLog messages from server to client
notifications/progressProgress updates for long-running operations
notifications/resources/list_changedServer's available resources have changed
notifications/resources/updatedA specific subscribed resource has changed
notifications/tools/list_changedServer's available tools have changed
notifications/prompts/list_changedServer's available prompts have changed
notifications/cancelledA request has been cancelled

Progress Tracking

For long-running operations, MCP supports progress notifications:

{
  "jsonrpc": "2.0",
  "method": "notifications/progress",
  "params": {
    "progressToken": "abc123",
    "progress": 50,
    "total": 100,
    "message": "Processing records..."
  }
}

The sender includes a progressToken in the request metadata, and the receiver can emit progress updates referencing that token.

03 / GAPS

What MCP Doesn't Include (Yet)

MCP's current logging primitive covers basic structured logging but lacks deeper observability features:

Active Proposal

There is an active proposal to add OpenTelemetry trace support to MCP, which would allow servers to emit OTel spans back to clients, enabling full-stack observability in agentic workflows.

04 / OPENTELEMETRY

OpenTelemetry Overview

OpenTelemetry (OTel) is an open-source observability framework under the Cloud Native Computing Foundation (CNCF) that provides a unified, vendor-neutral approach to collecting telemetry data.

The Three Pillars (Plus One)

OpenTelemetry standardizes collection of four observability signals:

SignalDescriptionUse Case
TracesRecords the path of a request through distributed servicesUnderstanding request flow, identifying bottlenecks
MetricsQuantitative measurements (counters, gauges, histograms)Monitoring health, alerting on thresholds
LogsTimestamped records of discrete eventsDebugging, audit trails
ProfilesCPU/memory usage snapshots (newer addition)Performance optimization

Key Concepts

Spans and Traces

Context Propagation

Resources

Architecture Components

┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│  Application    │     │  OTel Collector │     │   Backend       │
│  (SDK + API)    │────▶│  (optional)     │────▶│  (Jaeger,       │
│                 │     │                 │     │   Prometheus,   │
└─────────────────┘     └─────────────────┘     │   etc.)         │
                                                └─────────────────┘

Why It Matters for MCP

As agentic AI applications grow more complex—with multiple MCP calls, LLM interactions, and tool invocations—the ability to trace execution end-to-end becomes critical. Without tracing support:

The proposed OTel integration would allow MCP servers to emit spans that clients can forward to their observability backends, creating unified traces across the entire agent execution.

References

MCP Documentation

TopicURL
Architecture Overviewmodelcontextprotocol.io/docs/learn/architecture
Logging Specificationspec.modelcontextprotocol.io/.../logging/
Progress Trackingspec.modelcontextprotocol.io/.../progress/
Resources & Notificationsmodelcontextprotocol.info/docs/concepts/resources/
OTel Integration Proposalgithub.com/.../discussions/269

OpenTelemetry Documentation

TopicURL
Observability Primeropentelemetry.io/docs/concepts/observability-primer/
Specification Overviewopentelemetry.io/docs/specs/otel/overview/
Logs in OpenTelemetryopentelemetry.io/docs/specs/otel/logs/
Getting Startedopentelemetry.io/docs/getting-started/
Collectoropentelemetry.io/docs/collector/
Language SDKsopentelemetry.io/docs/languages/

Observability Backends (OTel-compatible)