Files
mcp-python-sdk/src/mcp/shared/exceptions.py
Allen Porter b89cabc7df fix: Add constructor for McpError to allow setting field
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.
2025-01-02 09:32:43 +00:00

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