---
source: https://iinventedlight.com/library/notes/otel-genai-mcp.md
title: "Instrument MCP client and server calls with OpenTelemetry"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (OpenTelemetry); Apache-2.0 (open-telemetry/semantic-conventions-genai (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: agent-operations
topic_area: "agent operations: OpenTelemetry MCP conventions"
tags: [opentelemetry, mcp, tracing, instrumentation]
client: Librarian
sources:
  - id: S1
    title: "Manual instrumentation for OpenTelemetry Python"
    publisher: OpenTelemetry
    url: https://opentelemetry.io/docs/languages/python/instrumentation/
    accessed: 2026-11-19
    license: "CC-BY-4.0"
  - id: S2
    title: "Semantic conventions for Model Context Protocol (MCP)"
    publisher: open-telemetry/semantic-conventions-genai (GitHub)
    url: https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/mcp.md
    accessed: 2026-11-19
    license: "Apache-2.0"
---
# 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

- [otel-genai-spans](https://iinventedlight.com/library/notes/otel-genai-spans/)
- [ao-mcp](https://iinventedlight.com/library/notes/ao-mcp/)
- [openai-agents-mcp](https://iinventedlight.com/library/notes/openai-agents-mcp/)

## Claims

- id: C1
  claim: Manual instrumentation means adding observability code to an app yourself.
  source: S1
  evidence: "Instrumentation is the act of adding observability code to an app yourself."

- id: C2
  claim: An app uses the OpenTelemetry SDK and API to emit telemetry.
  source: S1
  evidence: "use the OpenTelemetry SDK for your language"

- id: C3
  claim: MCP instrumentation should follow MCP semantic conventions rather than generic RPC conventions.
  source: S2
  evidence: "follow MCP conventions instead of [RPC semantic conventions]"

## Sources

- [S1] Manual instrumentation for OpenTelemetry Python. OpenTelemetry. https://opentelemetry.io/docs/languages/python/instrumentation/ . License: CC-BY-4.0. Accessed 2026-11-19.

- [S2] Semantic conventions for Model Context Protocol (MCP). open-telemetry/semantic-conventions-genai (GitHub). https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/mcp.md . License: Apache-2.0. Accessed 2026-11-19.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
