open-telemetry / open-telemetry/opentelemetry-python-contrib
[OpenAI Agents] MCP List Tools spans show only as "unknown" with no data
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Describe your environment
OS: macOS 26.2
Python version: Python 3.13.7
Package version: opentelemetry-instrumentation-openai-agents-v2 0.1.0
What happened?
Testing with OpenAI Agents SDK and an agent that has access to an MCP server, an "unknown" span is created when the agent fetches the list of MCP tools.
Steps to Reproduce
Run the following code, notice the OTEL console span output after the "DEBUG:openai.agents:Creating span <agents.tracing.span_data.MCPListToolsSpanData..." line
from agents import (
Agent,
Runner,
)
from agents.tracing import set_trace_processors
from agents.mcp.server import MCPServerStdio
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor, ConsoleSpanExporter
from opentelemetry.instrumentation.openai_agents import OpenAIAgentsInstrumentor
import asyncio
import logging
logging.basicConfig(level=logging.DEBUG)
# Clear default OpenAI tracing
set_trace_processors([])
# Configure OpenTelemetry tracing
provider = TracerProvider()
provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))
trace.set_tracer_provider(provider)
# Instrument OpenAI Agents with OpenTelemetry
OpenAIAgentsInstrumentor().instrument(tracer_provider=provider)
async def main():
print('calling agent')
async with MCPServerStdio(
name="Time",
params={
"command": "uvx",
"args": [
"mcp-server-time"
]
}
) as mcp_server:
agent = Agent(
name="MCP Agent",
instructions="You are an agent with access to a tool that can execute commands. Use this tool to execute the command and return the output. The tool will return the output of the command execution.",
model="gpt-4o-mini",
mcp_servers=[mcp_server]
)
llm_response = await Runner.run(
agent,
"What is the current time?"
)
result = llm_response.final_output
print(result)
if __name__ == "__main__":
asyncio.run(main())
Expected Result
A "list tools" span is created with server and result attributes mapped to gen_ai attributes.
Actual Result
An "unknown" span is created with no discerning attributes
{
"name": "unknown",
"context": {
"trace_id": "0x96f1903c189ce6e246b32a17d27d821a",
"span_id": "0x56ae050862eb125a",
"trace_state": "[]"
},
"kind": "SpanKind.INTERNAL",
"parent_id": "0x60f3483ad2f66fbb",
"start_time": "2026-02-13T04:25:24.052783Z",
"end_time": "2026-02-13T04:25:24.055009Z",
"status": {
"status_code": "OK"
},
"attributes": {
"gen_ai.operation.name": "unknown",
"gen_ai.provider.name": "openai",
"gen_ai.system": "openai",
"gen_ai.agent.name": "OpenAI Agent",
"gen_ai.agent.id": "agent",
"gen_ai.agent.description": "OpenAI Agents instrumentation",
"server.address": "api.openai.com",
"server.port": 443
},
"events": [],
"links": [],
"resource": {
"attributes": {
"telemetry.sdk.language": "python",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.version": "1.39.1",
"service.name": "unknown_service"
},
"schema_url": ""
}
}
Additional context
No response
Would you like to implement a fix?
None
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at OpenAIAgentsInstrumentor and trace how the OpenAI Agents MCPListToolsSpanData event is handled when the MCP server fetches its tools. Reproduce the example with MCPServerStdio and compare the emitted unknown span with the expected list-tools span; done means server and result attributes are mapped to gen_ai attributes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100