Skip to content

Commit 0423960

Browse files
committed
fix: use logger.exception instead of print for error logging
1 parent 67bbfc0 commit 0423960

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/snippets/clients/url_elicitation_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import asyncio
2626
import json
27+
import logging
2728
import webbrowser
2829
from typing import Any
2930
from urllib.parse import urlparse
@@ -34,6 +35,8 @@
3435
from mcp.shared.exceptions import McpError, UrlElicitationRequiredError
3536
from mcp.types import URL_ELICITATION_REQUIRED
3637

38+
logger = logging.getLogger(__name__)
39+
3740

3841
async def handle_elicitation(
3942
context: RequestContext[ClientSession, Any],
@@ -115,8 +118,8 @@ async def handle_url_elicitation(
115118
print(f"\nOpening browser to: {url}")
116119
try:
117120
webbrowser.open(url)
118-
except Exception as e:
119-
print(f"Failed to open browser: {e}")
121+
except Exception:
122+
logger.exception("Failed to open browser")
120123
print(f"Please manually open: {url}")
121124

122125
print("Waiting for you to complete the interaction in your browser...")

0 commit comments

Comments
 (0)