← All notes

Instrument MCP client and server calls with OpenTelemetry

Answer: Manual instrumentation adds OpenTelemetry SDK and API calls to an app so it emits traces. When instrumenting MCP calls, follow MCP conventions instead of RPC semantic conventions. MCP is based on JSON RPC, and context propagation uses W3C Trace Context.

Manual instrumentation

Instrumentation is the act of adding observability code to an app yourself. If you are instrumenting an app, use the OpenTelemetry SDK for your language. Use the SDK to initialize OpenTelemetry and the API to instrument your code. That emits telemetry from your app and from libraries that already ship instrumentation. If you are instrumenting a library, install only the API package; the library emits telemetry when it runs inside an app that uses the SDK. Set a tracer provider, then create a tracer with get_tracer. Decorators are common when one span should track an entire function.

MCP semantic conventions

Model Context Protocol is based on JSON RPC. When instrumenting MCP calls, follow MCP conventions instead of RPC semantic conventions, because MCP spans and metrics record domain-specific context, including message exchanges within streaming calls. The document covers client and server spans, context propagation, and metrics such as mcp.client.operation.duration. Trace context can go in the params._meta property bag on a tools/call request, including a traceparent. Status is Development.

| get_tracer | tracer | |---|---| | get_tracer | creates a tracer from the provider | | current span | typical way to start work | | tools/call | example MCP method | | traceparent | included in context propagation examples |

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: OpenTelemetry, Manual instrumentation for OpenTelemetry Python; open-telemetry/semantic-conventions-genai (GitHub), Semantic conventions for Model Context Protocol (MCP). CC-BY-4.0; Apache-2.0. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: OpenTelemetry, Manual instrumentation for OpenTelemetry Python; open-telemetry/semantic-conventions-genai (GitHub), Semantic conventions for Model Context Protocol (MCP). CC-BY-4.0; Apache-2.0.

Cite this

Permanent ID: iil:note:7be4vngr

iinventedlight. 2026. "Instrument MCP client and server calls with OpenTelemetry." iinventedlight Library, iil:note:7be4vngr, version of 2026-11-19. https://iinventedlight.com/library/notes/otel-genai-mcp/. License: CC-BY-4.0.

@misc{iil_note_7be4vngr,
  author = {{iinventedlight}},
  title = {{Instrument MCP client and server calls with OpenTelemetry}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-19},
  url = {https://iinventedlight.com/library/notes/otel-genai-mcp/},
  note = {Permanent ID iil:note:7be4vngr. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/otel-genai-mcp.md.