Skip to content

Commit

Permalink
fix: Add constructor for McpError to allow setting field
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
allenporter authored and dsp-ant committed Jan 2, 2025
1 parent 312e9da commit b89cabc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/mcp/shared/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ class McpError(Exception):
"""

error: ErrorData

def __init__(self, error: ErrorData):
"""Initialize McpError."""
super().__init__(error.message)
self.error = error

0 comments on commit b89cabc

Please sign in to comment.