fix(mcp): honor TRACELOOP_TRACE_CONTENT in transport instrumentation - #4441
fix(mcp): honor TRACELOOP_TRACE_CONTENT in transport instrumentation#4441pacocartones wants to merge 1 commit into
Conversation
The transport-level MCP instrumentation recorded tool call arguments, tool results and MCP response values onto spans unconditionally, ignoring TRACELOOP_TRACE_CONTENT. That content is third-party data (it may contain end-user PII), and every other instrumentation - including the FastMCP wrapper in this same package - honors the flag. Gate the content attributes behind should_send_prompts().
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughMCP instrumentation now gates prompt and response content attributes with ChangesMCP prompt privacy
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: 🔵 Low · up to The change gates transport-level MCP content attributes on TRACELOOP_TRACE_CONTENT, but the enabled regression test may be satisfied by a separate FastMCP span rather than the transport span, leaving the privacy fix insufficiently verified. The PR is mergeable with explicit follow-up to scope assertions to transport spans. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The transport-level MCP instrumentation (
packages/opentelemetry-instrumentation-mcp) recorded tool call arguments, tool results and MCP response values onto spans unconditionally, ignoringTRACELOOP_TRACE_CONTENT.That content is third-party data — tool call arguments and results may contain end-user PII — and every other instrumentation in this repo, including the FastMCP wrapper in this same package (
_should_send_prompts()), honors the flag. The transport-level path was the one place that did not, so operators who setTRACELOOP_TRACE_CONTENT=falsestill had tool inputs/outputs captured on spans.This adds a
should_send_prompts()helper toutils.py(mirroring the FastMCP one) and gates the three content attributes (TRACELOOP_ENTITY_INPUT,TRACELOOP_ENTITY_OUTPUT,MCP_RESPONSE_VALUE) behind it. Error/status handling (isError) stays outside the gate.Adds
tests/test_content_privacy.py: withTRACELOOP_TRACE_CONTENT=falseno secret leaks onto any span; with it enabled the content is still captured. RED before the fix, GREEN after; no regression.Summary by CodeRabbit
New Features
TRACELOOP_TRACE_CONTENT.Bug Fixes