Skip to content

fix(shared): make UrlElicitationRequiredError pickle-safe - #3262

Open
ulofiai wants to merge 2 commits into
modelcontextprotocol:mainfrom
ulofiai:fix/issue-2431
Open

fix(shared): make UrlElicitationRequiredError pickle-safe#3262
ulofiai wants to merge 2 commits into
modelcontextprotocol:mainfrom
ulofiai:fix/issue-2431

Conversation

@ulofiai

@ulofiai ulofiai commented Aug 7, 2026

Copy link
Copy Markdown

Fixes #2431.

The constructor shape reported for McpError no longer exists on main: MCPError now stores (code, message, data) in Exception.args, so the base class already survives pickle round-trips. UrlElicitationRequiredError still inherits those arguments even though its constructor accepts (elicitations, message=None), causing both pickle and cloudpickle to call it with the wrong arity during unpickling.

Add an explicit __reduce__ that reconstructs the subclass through its original constructor signature. This preserves the exception type, message, structured error payload, and typed elicitation list. Add regression coverage for both the base MCPError contract and the URL-elicitation subclass.

Tests:

  • tests/shared/test_exceptions.py (12 passed)
  • direct pickle and cloudpickle==3.1.2 round-trips

Signed-off-by: ulofiai <monsterking@tutamail.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

Signed-off-by: ulofiai <monsterking@tutamail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

McpError is not pickle-safe and fails to unpickle

1 participant