OpenInference MCP Instrumentation

OpenTelemetry auto-instrumentation for the Model Context Protocol (MCP) Python SDK that propagates trace context across tool calls.

Library
PyPI
v2.0.10
1,237 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
92 /100 Excellent
Development Activity 100
Maintenance 100
Community 80
Maturity 48
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
82 /100 Excellent
Architecture 82
Code Quality 85
Innovation 80
Learning Curve 80

OpenInference MCP Instrumentation is a Python auto-instrumentation library for the Model Context Protocol (MCP) SDK, part of Arize’s OpenInference project for AI observability. It hooks MCP’s client and server transports so that the OpenTelemetry span active when a tool call is made stays connected to the spans generated while that call executes on the other side of the protocol.

Because MCP crosses a client/server boundary, traces would otherwise break at the transport. This package fixes that by injecting and extracting OpenTelemetry context through streamable HTTP, SSE, and stdio transports, giving you unbroken distributed traces across your agent and its MCP tool servers. It focuses purely on context propagation and does not emit its own telemetry.

What You Get

  • A single MCPInstrumentor you register once to patch MCP client and server transports
  • Automatic OpenTelemetry context propagation across streamable HTTP, SSE, and stdio transports
  • Unbroken distributed traces spanning your agent and its MCP tool servers
  • Seamless integration with Phoenix, Arize AX, and any OpenTelemetry-compatible backend
  • A lightweight, dependency-light install that adds no telemetry of its own

Common Use Cases

  • Tracing LLM agents that call tools over the Model Context Protocol
  • Connecting client-side and server-side spans in an MCP-based system
  • Feeding coherent agent traces into Phoenix or Arize AX for debugging

Under The Hood

Architecture The package ships a single MCPInstrumentor extending OpenTelemetry’s BaseInstrumentor. On _instrument, it uses wrapt’s post-import hooks to wrap MCP’s transport entry points (mcp.client.streamable_http, mcp.server.streamable_http, mcp.client.sse, mcp.server.sse, and stdio) so that outgoing requests inject the current context via opentelemetry.propagate and incoming requests extract it, re-activating the span on the far side.

Tech Stack Pure Python built directly on the OpenTelemetry API and instrumentation SDK, plus wrapt for non-invasive monkeypatching. It declares MCP as an instrumentation dependency and lives in the Arize-ai/openinference monorepo under python/instrumentation/openinference-instrumentation-mcp, versioned and published independently.

Code Quality The monorepo carries 132 Python test files across its instrumentation packages and a shared CI/tooling setup, and the MCP module itself is small and tightly scoped with typed signatures. Its narrow responsibility (context only, no telemetry) keeps the surface easy to reason about and audit.

API Design Integration is a one-liner: instantiate MCPInstrumentor().instrument() and every supported MCP transport is patched automatically, requiring no changes to tool code. The design intentionally avoids emitting spans so it layers cleanly beneath framework-specific instrumentors.

Used by 24 apps in this directory

TypeScript
56%
Other

agenta

AI Development · Developer Tools · Devops

4,788

The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
TypeScript 56%
Python 39%
Updated 1 weeks ago
TypeScript
56%
Other

agenta

AI Development · Developer Tools · Devops

4,788

The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
TypeScript 56%
Python 39%
Updated 1 weeks ago
Python
100%
Apache 2.0

Agno

AI Development · Automation · Devops

42,358

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python 100%
Updated 1 weeks ago
Python
100%
Apache 2.0

Agno

AI Development · Automation · Devops

42,358

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python 100%
Updated 1 weeks ago
Python
100%
Apache 2.0

Agno

AI Development · Automation · Devops

42,358

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python 100%
Updated 1 weeks ago
Python
69%
MIT

Langflow

AI Agents · AI Development

155,319

Build, test, and deploy AI agents and RAG workflows visually with native API and MCP server export.

View details
90
Repo Health
85
Technical
65
Dependency
Built with
Python 69%
TypeScript 22%
Updated 1 weeks ago
TypeScript
78%
LGPL 3.0

Latitude

AI Agents · Monitoring

4,686

Open-source AI agent monitoring that catches what will break next before your users do.

View details
86
Repo Health
88
Technical
67
Dependency
Built with
TypeScript 78%
Rust 11%
Python 11%
Updated 2 weeks ago
TypeScript
78%
LGPL 3.0

Latitude

AI Agents · Monitoring

4,686

Open-source AI agent monitoring that catches what will break next before your users do.

View details
86
Repo Health
88
Technical
67
Dependency
Built with
TypeScript 78%
Rust 11%
Python 11%
Updated 2 weeks ago
TypeScript
78%
LGPL 3.0

Latitude

AI Agents · Monitoring

4,686

Open-source AI agent monitoring that catches what will break next before your users do.

View details
86
Repo Health
88
Technical
67
Dependency
Built with
TypeScript 78%
Rust 11%
Python 11%
Updated 2 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers