Skip to content

Add MCP tool call spans#15659

Merged
nicholasclark-openai merged 11 commits intomainfrom
nicholasclark/2026-03-23-server-spans
Mar 25, 2026
Merged

Add MCP tool call spans#15659
nicholasclark-openai merged 11 commits intomainfrom
nicholasclark/2026-03-23-server-spans

Conversation

@nicholasclark-openai
Copy link
Contributor

@nicholasclark-openai nicholasclark-openai commented Mar 24, 2026

Summary

  • add an explicit mcp.tools.call span around MCP tool execution in core
  • keep MCP span validation local to mcp_tool_call_tests instead of broadening the integration test suite
  • inline the turn/session correlation fields directly in the span initializer

Included Changes

  • codex-rs/core/src/mcp_tool_call.rs: wrap the existing MCP tool call in mcp.tools.call and inline conversation.id, session.id, and turn.id in the span initializer
  • codex-rs/core/src/mcp_tool_call_tests.rs: assert the MCP span records the expected correlation and server fields

Testing

  • cargo test -p codex-core
  • just fmt

Notes

nicholasclark-openai and others added 7 commits March 23, 2026 13:22
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Propagate connector id and connector name into the mcp.tools.call span and add tracing coverage for Codex Apps and stdio MCP paths.

Co-authored-by: Codex <noreply@openai.com>
Drop the Responses-specific tracing changes from this branch so the draft PR focuses on MCP spans and MCP transport timing.

Co-authored-by: Codex <noreply@openai.com>
@nicholasclark-openai nicholasclark-openai changed the title Add outbound spans for responses and MCP Add MCP tool call spans Mar 25, 2026
nicholasclark-openai and others added 3 commits March 25, 2026 11:28
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Keep the narrow MCP span PR out of the integration test suite by asserting the span fields in mcp_tool_call_tests instead.

Co-authored-by: Codex <noreply@openai.com>
@nicholasclark-openai nicholasclark-openai marked this pull request as ready for review March 25, 2026 20:11
let conversation_id = session.conversation_id.to_string();
span.record("conversation.id", conversation_id.as_str());
span.record("session.id", conversation_id.as_str());
span.record("turn.id", turn_context.sub_id.as_str());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: interesting, why do it like this instead of defining inline above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex decision that I missed. It was just a compile-time/runtime split

@nicholasclark-openai nicholasclark-openai changed the title Add MCP tool call spans Add MCP tool call spans and metric tags Mar 25, 2026
@nicholasclark-openai nicholasclark-openai force-pushed the nicholasclark/2026-03-23-server-spans branch 2 times, most recently from 6f5cefc to 16d57b4 Compare March 25, 2026 21:28
Co-authored-by: Codex <noreply@openai.com>
@nicholasclark-openai nicholasclark-openai force-pushed the nicholasclark/2026-03-23-server-spans branch from 16d57b4 to 89161d4 Compare March 25, 2026 21:40
@nicholasclark-openai nicholasclark-openai changed the title Add MCP tool call spans and metric tags Add MCP tool call spans Mar 25, 2026
@nicholasclark-openai nicholasclark-openai enabled auto-merge (squash) March 25, 2026 21:55
@nicholasclark-openai nicholasclark-openai merged commit b652451 into main Mar 25, 2026
36 checks passed
@nicholasclark-openai nicholasclark-openai deleted the nicholasclark/2026-03-23-server-spans branch March 25, 2026 22:13
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2026
@nicholasclark-openai nicholasclark-openai restored the nicholasclark/2026-03-23-server-spans branch March 25, 2026 22:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants