{"id":24162,"library":"openinference-instrumentation-mcp","title":"OpenInference MCP Instrumentation","description":"OpenInference instrumentation for MCP (Model Context Protocol) clients, enabling OpenTelemetry-based tracing of MCP tool calls and server interactions. Current version 2.0.0, requires Python >=3.10 <3.15. Part of the Arize AI OpenInference ecosystem. Active development with frequent releases.","status":"active","version":"2.0.0","language":"python","source_language":"en","source_url":"https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-mcp","tags":["openinference","mcp","model-context-protocol","opentelemetry","tracing","observability","arize"],"install":[{"cmd":"pip install openinference-instrumentation-mcp","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Core instrumentation base classes and utilities","package":"openinference-instrumentation","optional":false},{"reason":"Required to instrument MCP client sessions","package":"mcp","optional":false},{"reason":"Semantic convention constants for OpenInference spans","package":"openinference-semantic-conventions","optional":false},{"reason":"OpenTelemetry API for span creation and context propagation","package":"opentelemetry-api","optional":false},{"reason":"Used for monkey-patching MCP client methods","package":"wrapt","optional":false}],"imports":[{"note":"","wrong":"","symbol":"MCPClientInstrumentor","correct":"from openinference_instrumentation_mcp import MCPClientInstrumentor"}],"quickstart":{"code":"import os\nfrom opentelemetry import trace\nfrom opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import SimpleSpanProcessor\n\nfrom openinference_instrumentation_mcp import MCPClientInstrumentor\n\n# Set up OpenTelemetry tracer provider\nprovider = TracerProvider()\nprovider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint=os.environ.get('OTEL_EXPORTER_OTLP_ENDPOINT', 'http://localhost:4318/v1/traces'))))\ntrace.set_tracer_provider(provider)\n\n# Instrument MCP client\nMCPClientInstrumentor().instrument()\n\n# Now any MCP client sessions will be traced.","lang":"python","description":"Instrument MCP client with OpenInference tracing."},"warnings":[{"fix":"Upgrade MCP library to version that supports streamable_http_client (mcp>=1.6.0). Review your MCP server's streaming transport.","message":"Version 2.0.0 introduces a BREAKING CHANGE: support for streamable_http_client. Existing instrumentations using older MCP client versions may break. Update MCP library to compatible version.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Call MCPClientInstrumentor().instrument() immediately after setting up the tracer provider and before importing/using mcp.ClientSession or any MCP client.","message":"Instrumentation must be set up before creating any MCP client sessions. If MCP client is imported and used before calling MCPClientInstrumentor().instrument(), the instrumentation will not apply.","severity":"gotcha","affected_versions":"all"},{"fix":"Use a separate OpenInference instrumentation for your MCP server (e.g., openinference-instrumentation-mcp-server) if available.","message":"The instrumentation only instruments the client side, not the server. Do not expect server-side spans unless you set up instrumentation on the server as well.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure wrapt is installed. For wrapt 2.x compatibility, use openinference-instrumentation>=0.1.47.","message":"Wrapt 2.x is supported, but older instrumentations may require wrapt<2. If you encounter import errors related to wrapt, check compatibility.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure you call trace.set_tracer_provider(provider) before MCPClientInstrumentor().instrument(), and ensure instrumentation is called before any MCP client session.","cause":"Tracer provider not set up or instrumentation() not called before MCP client usage.","error":"No spans are being created"},{"fix":"Use 'from openinference_instrumentation_mcp import MCPClientInstrumentor'.","cause":"Wrong import path. The symbol is in the top-level package, not a submodule.","error":"MCPClientInstrumentor not found"},{"fix":"Install wrapt: 'pip install wrapt'. For wrapt 2.x support, upgrade openinference-instrumentation to >=0.1.47.","cause":"wrapt is missing or incompatible version.","error":"Could not import wrapt"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}