-
Notifications
You must be signed in to change notification settings - Fork 4k
Introduce typed error classes with metadata #1742
Copy link
Copy link
Open
Labels
P2Moderate issues affecting some users, edge cases, potentially valuable featureModerate issues affecting some users, edge cases, potentially valuable featurebreaking changeWill break existing deployments when updated without changesWill break existing deployments when updated without changesenhancementRequest for a new feature that's not currently supportedRequest for a new feature that's not currently supportedv2Affects the v2 line (2.x on main)Affects the v2 line (2.x on main)
Description
Activity
Metadata
Metadata
Assignees
Labels
P2Moderate issues affecting some users, edge cases, potentially valuable featureModerate issues affecting some users, edge cases, potentially valuable featurebreaking changeWill break existing deployments when updated without changesWill break existing deployments when updated without changesenhancementRequest for a new feature that's not currently supportedRequest for a new feature that's not currently supportedv2Affects the v2 line (2.x on main)Affects the v2 line (2.x on main)
Summary
Replace generic exceptions with SDK-native error classes that include useful metadata like fault attribution, retryability, and HTTP details.
Problem
The SDK currently raises generic exceptions from various layers (httpx, anyio, task groups) with no context about:
This makes it hard for users to build robust error handling.
Goal
A hierarchy of typed errors like:
McpError(base) withfault,is_retryable,http_status_code,response_bodyMcpTransportErrorfor connection/network issuesMcpProtocolErrorfor invalid JSON-RPC responsesMcpAuthErrorfor 401/403 responsesAI Disclaimer