Skip to content

feat(mcp): Add MCP data collection gating - #7154

Open
ericapisani wants to merge 2 commits into
masterfrom
py-2588-mcp
Open

feat(mcp): Add MCP data collection gating#7154
ericapisani wants to merge 2 commits into
masterfrom
py-2588-mcp

Conversation

@ericapisani

Copy link
Copy Markdown
Member

Refs PY-2588
Refs #6748

@ericapisani
ericapisani requested a review from a team as a code owner August 10, 2026 18:55
@linear-code

linear-code Bot commented Aug 10, 2026

Copy link
Copy Markdown

PY-2588

@github-actions

Copy link
Copy Markdown
Contributor

Codecov Results 📊

104402 passed | ⏭️ 6677 skipped | Total: 111079 | Pass Rate: 93.99% | Execution Time: 360m 22s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +418
Passed Tests 📈 +418
Failed Tests
Skipped Tests

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 2485 uncovered lines.
❌ Project coverage is 90.13%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    90.14%    90.13%    -0.01%
==========================================
  Files          193       193         —
  Lines        25147     25183       +36
  Branches      9136      9176       +40
==========================================
+ Hits         22669     22698       +29
- Misses        2478      2485        +7
- Partials      1431      1431         —

Generated by Codecov Action

Comment on lines +2104 to +2108
}

if span_streaming:
items = capture_items("span")
with sentry_sdk.traces.start_span(name="mcp tx"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MCP tool arguments leak to spans when send_default_pii=False

Tool arguments are only gated inside has_data_collection_enabled; when data_collection is not configured they are attached to spans unconditionally, bypassing the user's send_default_pii=False setting.

Evidence
  • The test case no-data-collection-falls-back-to-send-default-pii sets expect_input=False for data_collection=None, send_default_pii=False, but the assertion if expect_input or data_collection is None forces the test to verify that arguments are still collected.
  • In sentry_sdk/integrations/mcp.py, _tool_handler_wrapper only clears arguments inside if has_data_collection_enabled(client.options).
  • When data_collection is not configured the code falls through to _set_span_input_data(span, ..., arguments, ...) with the original arguments dict, serializing potentially sensitive values into span data regardless of PII settings.

Identified by Warden · find-bugs · AF3-N8U

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.

1 participant