Skip to content

Commit 5f80585

Browse files
Handling TODO mentioned in the lowlevel/server.py.
Initital commit, need feedback.
1 parent e80c015 commit 5f80585

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/mcp/server/lowlevel/server.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,19 @@ async def _handle_message(
536536
)
537537
case types.ClientNotification(root=notify):
538538
await self._handle_notification(notify)
539+
case Exception():
540+
logger.error(f"Received error message: {message}")
541+
if raise_exceptions:
542+
raise message
543+
# Send the error as a notification since we don't have a request context
544+
await session.send_log_message(
545+
level="error",
546+
data=types.ErrorData(
547+
code=types.INTERNAL_ERROR,
548+
message=str(message),
549+
data=None
550+
)
551+
)
539552

540553
for warning in w:
541554
logger.info(f"Warning: {warning.category.__name__}: {warning.message}")

0 commit comments

Comments
 (0)