mirror of
https://github.com/aljazceru/mcp-python-sdk.git
synced 2025-12-19 06:54:18 +01:00
Backport of #116 by @allenporter to v1.1.x branch. Fixes an issue where exception handling code fails with AttributeError when accessing the error field of McpError.
15 lines
316 B
Python
15 lines
316 B
Python
from mcp.types import ErrorData
|
|
|
|
|
|
class McpError(Exception):
|
|
"""
|
|
Exception type raised when an error arrives over an MCP connection.
|
|
"""
|
|
|
|
error: ErrorData
|
|
|
|
def __init__(self, error: ErrorData):
|
|
"""Initialize McpError."""
|
|
super().__init__(error.message)
|
|
self.error = error
|