feat(mcp): Migrate to span first #6131
3 issues
High
Duplicate function definition for _set_span_data_attribute - `sentry_sdk/ai/utils.py:505-511`
The function _set_span_data_attribute is defined twice in this file - once at lines 505-511 and again at lines 514-520. In Python, the second definition silently overrides the first. While both definitions appear identical in this case, duplicate function definitions are a code smell and indicate a copy-paste error during the PR. This will work at runtime but creates maintenance confusion and suggests unintended code duplication.
Medium
_set_span_data_attribute is defined twice, causing dead code - `sentry_sdk/ai/utils.py:502-511`
The function _set_span_data_attribute is defined at line 505-511 and again at line 514-520. Both definitions are identical. The first definition becomes dead code since Python's module-level function definitions overwrite previous ones. While this doesn't change runtime behavior due to identical implementations, it indicates a merge conflict or copy-paste error that should be cleaned up.
Low
Non-streaming path in test_resource_handler_with_error lacks span status assertion - `tests/integrations/mcp/test_mcp.py:919-936`
The span streaming path asserts span["status"] == "error" and checks SPANDATA.MCP_TOOL_RESULT_IS_ERROR not in span["attributes"] (lines 917-918), but the non-streaming path (lines 919-936) only verifies the error event payload without asserting on the span's error status. This asymmetry means the non-streaming path has less test coverage for verifying that errors properly propagate to the span status.
4 skills analyzed
| Skill | Findings | Duration | Cost |
|---|---|---|---|
| code-review | 2 | 6m 11s | $3.36 |
| find-bugs | 1 | 9m 46s | $6.36 |
| skill-scanner | 0 | 5m 35s | $1.46 |
| security-review | 0 | 7m 3s | $2.09 |
Duration: 28m 35s · Tokens: 7.1M in / 63.8k out · Cost: $13.29 (+extraction: $0.00, +merge: $0.00, +fix_gate: $0.01, +dedup: $0.00)