feat(mcp): Add MCP data collection gating - #7154
Open
ericapisani wants to merge 2 commits into
Open
Conversation
Refs PY-2588 Refs #6748
Contributor
Codecov Results 📊✅ 104402 passed | ⏭️ 6677 skipped | Total: 111079 | Pass Rate: 93.99% | Execution Time: 360m 22s 📊 Comparison with Base Branch
All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 2485 uncovered lines. 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"): |
Contributor
There was a problem hiding this comment.
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-piisetsexpect_input=Falsefordata_collection=None, send_default_pii=False, but the assertionif expect_input or data_collection is Noneforces the test to verify that arguments are still collected. - In
sentry_sdk/integrations/mcp.py,_tool_handler_wrapperonly clearsargumentsinsideif has_data_collection_enabled(client.options). - When
data_collectionis 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs PY-2588
Refs #6748