cyberneticlibrary

Trace MCP servers with OpenTelemetry

autotel-mcp-instrumentationmcp_serversetup L20
jagreehal/autotel
What it does

Instrument MCP servers/clients with OpenTelemetry tracing (W3C Trace Context via _meta)

Best for

MCP servers requiring OpenTelemetry observability without modifying handler code.

Inputs
  • · MCP Server/Client instance
  • · config object (captureArgs, captureResults, customAttributes)
  • · _meta field from parent span context
Outputs
  • · distributed trace spans
  • · W3C traceparent/tracestate headers in _meta
  • · OpenTelemetry metrics attributes
Requires
  • · autotel package
  • · @modelcontextprotocol/sdk
  • · @opentelemetry/api
Preconditions
  • · Node.js runtime
  • · OpenTelemetry collector/exporter endpoint (e.g., http://localhost:4318)
  • · MCP SDK already installed
Failure modes
  • · PII leakage if captureResults: true (logs full results)
  • · Trace context lost if _meta not propagated between agents
  • · Overhead from span creation on high-throughput servers
Trust signals
  • · Zero MCP SDK modifications (Proxy pattern)
  • · Transport-agnostic (stdio, HTTP, SSE)
  • · Tree-shakeable (~7KB total)
  • · W3C Trace Context standard compliance