Skip to content

fix(openai-agents): add MCPListToolsSpanData support (#4197)#4

Closed
nagkumar91 wants to merge 1 commit into
mainfrom
fix/4197-mcp-list-tools
Closed

fix(openai-agents): add MCPListToolsSpanData support (#4197)#4
nagkumar91 wants to merge 1 commit into
mainfrom
fix/4197-mcp-list-tools

Conversation

@nagkumar91

Copy link
Copy Markdown
Owner

Summary

Fixes open-telemetry#4197 — MCP List Tools spans show only as 'unknown' with no data.

Problem

The OpenAI Agents SDK emits MCPListToolsSpanData spans (with type="mcp_tools") when fetching MCP server tool lists, but the OTel instrumentation didn't import or handle this type, causing these spans to get operation_name="unknown" with no useful attributes.

Changes

  • Import MCPListToolsSpanData in both the try and except import blocks in span_processor.py
  • Operation name mapping: Returns "mcp.list_tools" for MCPListToolsSpanData
  • Span kind: Returns SpanKind.CLIENT (MCP server interaction is a client call)
  • Attribute extraction: Extracts mcp.server.name, mcp.tools.count, and mcp.tools.list (sensitive)
  • Generic fallback: Uses span_data.type for future unrecognized SDK span types instead of "unknown"
  • Test stubs: Added MCPListToolsSpanData dataclass with server, result, and type fields
  • Unit test: Verifies the span gets proper operation name, server name attribute, and CLIENT span kind

Testing

All 104 tests pass, including the new test_mcp_list_tools_span test.

…4197)

The OpenAI Agents SDK emits MCPListToolsSpanData spans when fetching
MCP server tool lists, but the instrumentation did not recognize this
type, producing "unknown" spans with no data.

Adds MCPListToolsSpanData handling with proper operation name
(mcp.list_tools), span kind (CLIENT), and attribute extraction
(mcp.server.name, mcp.tools.count, mcp.tools.list).

Also adds a generic .type-based fallback so future unrecognized SDK
span types get a meaningful name instead of "unknown".

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[OpenAI Agents] MCP List Tools spans show only as "unknown" with no data

1 participant