Skip to content

Commit f2cb5b4

Browse files
fix(mcp): Add None checks (#6219)
1 parent 81c4c33 commit f2cb5b4

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

sentry_sdk/integrations/mcp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ async def _handler_wrapper(
495495
uri = original_kwargs.get("uri")
496496

497497
protocol = None
498-
if hasattr(uri, "scheme"):
498+
if uri is not None and hasattr(uri, "scheme"):
499499
protocol = uri.scheme
500500
elif handler_name and "://" in handler_name:
501501
protocol = handler_name.split("://")[0]
@@ -638,7 +638,7 @@ def _patch_fastmcp() -> None:
638638
This function patches the _get_prompt_mcp and _read_resource_mcp methods
639639
to add instrumentation for those handlers.
640640
"""
641-
if hasattr(FastMCP, "_get_prompt_mcp"):
641+
if FastMCP is not None and hasattr(FastMCP, "_get_prompt_mcp"):
642642
original_get_prompt_mcp = FastMCP._get_prompt_mcp
643643

644644
@wraps(original_get_prompt_mcp)
@@ -655,7 +655,7 @@ async def patched_get_prompt_mcp(
655655

656656
FastMCP._get_prompt_mcp = patched_get_prompt_mcp
657657

658-
if hasattr(FastMCP, "_read_resource_mcp"):
658+
if FastMCP is not None and hasattr(FastMCP, "_read_resource_mcp"):
659659
original_read_resource_mcp = FastMCP._read_resource_mcp
660660

661661
@wraps(original_read_resource_mcp)

0 commit comments

Comments
 (0)