Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sentry_sdk/integrations/mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ async def _handler_wrapper(
uri = original_kwargs.get("uri")

protocol = None
if hasattr(uri, "scheme"):
if uri is not None and hasattr(uri, "scheme"):
protocol = uri.scheme
elif handler_name and "://" in handler_name:
protocol = handler_name.split("://")[0]
Expand Down Expand Up @@ -638,7 +638,7 @@ def _patch_fastmcp() -> None:
This function patches the _get_prompt_mcp and _read_resource_mcp methods
to add instrumentation for those handlers.
"""
if hasattr(FastMCP, "_get_prompt_mcp"):
if FastMCP is not None and hasattr(FastMCP, "_get_prompt_mcp"):
original_get_prompt_mcp = FastMCP._get_prompt_mcp

@wraps(original_get_prompt_mcp)
Expand All @@ -655,7 +655,7 @@ async def patched_get_prompt_mcp(

FastMCP._get_prompt_mcp = patched_get_prompt_mcp

if hasattr(FastMCP, "_read_resource_mcp"):
if FastMCP is not None and hasattr(FastMCP, "_read_resource_mcp"):
original_read_resource_mcp = FastMCP._read_resource_mcp

@wraps(original_read_resource_mcp)
Expand Down
Loading