Skip to content

Commit b89cabc

Browse files
allenporterdsp-ant
authored andcommitted
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.
1 parent 312e9da commit b89cabc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: src/mcp/shared/exceptions.py

+5
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ class McpError(Exception):
77
"""
88

99
error: ErrorData
10+
11+
def __init__(self, error: ErrorData):
12+
"""Initialize McpError."""
13+
super().__init__(error.message)
14+
self.error = error

0 commit comments

Comments
 (0)