Skip to content

ref(mcp): Remove unused _extract_tool_result_content helper - #8422

Merged
sentrivana merged 1 commit into
masterfrom
ref/mcp-remove-unused-extract-tool-result-content
Nov 30, 2026
Merged

sentrivana merged 1 commit into
masterfrom
ref/mcp-remove-unused-extract-tool-result-content

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Description

Removes _extract_tool_result_content() from sentry_sdk/integrations/mcp.py (39 lines). Nothing calls it.

Why it's dead

  • feat(integrations): MCP Python SDK #4964 added it with the MCP integration. It turned the return value of a patched low-level server tool handler (CallToolResult, a (unstructured, structured) tuple, a dict, or a list of content blocks) into the value for the tool result span attribute.
  • chore(mcp): Drop support for < 2.0 #7508 (chore(mcp): Drop support for < 2.0) replaced that handler patching with the server middleware and deleted the only call (extracted = _extract_tool_result_content(result)). The definition stayed behind.
  • On mcp 2.x, _instrument_tool_call gets the result as a dict and reads structuredContent or content from it inline. It calls _extract_text_from_content_blocks directly, and this PR keeps that function.
  • git grep _extract_tool_result_content on master finds only the definition. git log -S "_extract_tool_result_content(" finds only the two PRs above. The helper is private and isn't exported or documented.

Why it's safe

Nothing reaches the function, so no behavior changes. Public API, supported mcp versions, and dependencies stay the same. No open PR or issue mentions it. The only open PR that touches mcp.py, #8404, edits other lines, so it shouldn't conflict.

Why it's better gone

A reader of mcp.py today sees two ways tool results get extracted, and only the inline one runs. The dead helper also documents result shapes (tuple, CallToolResult object) that the middleware path never receives.

Issues

None.

via automation sched_65eed06cc199036c2b13411096f412d4 · Run ID sched_65eed06cc199036c2b13411096f412d4:1796025600000.

--

View Session [Sentry]

The only caller was the low-level server handler patching that #7508
removed when dropping support for mcp < 2.0. The middleware-based
_instrument_tool_call reads structuredContent/content from the result
dict directly, so the helper has been unreachable since then.
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 8c15368.

Main concerns: data sent to Sentry, reach.

This label is a hint for reviewers, not an approval.

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 59457 passed | ⏭️ 3119 skipped | Total: 62576 | Pass Rate: 95.02% | Execution Time: 158m 2s

📊 Comparison with Base Branch

Metric Change
Total Tests —
Passed Tests 📈 +1
Failed Tests 📉 -1
Skipped Tests —

✨ Test counts unchanged from base.

All tests are passing successfully.

✅ Patch coverage is 100.00% (no changed executable lines found; target 80%).
Project statement coverage is 90.17% (up 0.06 percentage points from base (566beb0) to head (8c15368)).

Files with missing lines (1)
File Coverage % Lines
sentry_sdk/integrations/mcp.py 93.81% ⚠️ 12 Missing and 22 partials
Coverage diff
@@            Coverage Diff             @@
##        master     #8422       +/-##
==========================================
+ Coverage    90.11%    90.17%    +0.06%
==========================================
  Files          201       201         —
  Tracked lines     22199     22184       -15
  Branches      7784      7772       -12
==========================================
- Hits         20004     20003        -1
+ Misses        2195      2181       -14
  Partials      1283      1283         —

Generated by Coverage Action

@sentrivana
sentrivana marked this pull request as ready for review November 30, 2026 08:14
@sentrivana
sentrivana requested a review from a team as a code owner November 30, 2026 08:14
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 30, 2026
@sentrivana
sentrivana merged commit edb9135 into master Nov 30, 2026
176 checks passed
@sentrivana
sentrivana deleted the ref/mcp-remove-unused-extract-tool-result-content branch November 30, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants