What this thread does
Do first: migrate to v2.0.0 and replace the old McpError(ErrorData(...)) construction with the v2 MCPError(code, message, data=None) API.
Symptom
AttributeError: 'str' object has no attribute 'message' occurs during unpickling, reported by rain87 using mcp==1.26.0. It can surface in background tasks but the issue reproducer isolates the exception round-trip. Other users faridun-m, ghost and mikemikimike report the same base-exception reconstruction problem.
Cause
The old constructor expects an ErrorData object, but stores its message string in the base exception arguments. Pickle reconstructs the exception from those arguments and therefore supplies a string. The v2 refactor aligns the constructor and stored arguments: both carry code, message and data.
Fix
1. Migrate the SDK and exception handling to the stable v2 release v2.0.0 (release). 2. Use MCPError, with its uppercase name and separate code, message and optional data parameters. This is a constructor change, not just a rename (PR). 3. For an existing ErrorData object, the refactor supplies MCPError.from_error_data(error) rather than the old one-argument constructor.
Fixed in
PR #1956 merged 2026-01-26. Its merge is already present in v2.0.0a1 (released 2026-06-11), the first v2 alpha. Stable v2.0.0 (released 2026-07-28) also contains it. The closing maintainer confirms the base MCPError case is fixed on 2.x and says v1.x accepts only critical and security fixes.
If it still fails
- Do not assume the old v1 constructor is accepted after migration: v2 takes separate parameters.
- The closing statement covers the base
MCPError; comments separately report a constructor mismatch inUrlElicitationRequiredError. This base-exception fix does not establish that every subclass survives serialization. - The closure does not promise a v1 backport.
Not for: typing.Dict return values wrapped in result; see ptr-mcp-python-sdk-typing-dict-return-wrapped-in-result-structured-output.
Sources
- McpError is not pickle-safe and fails to unpickle, rain87, opened 2026-04-13; closed as completed on 2026-10-14: "Unpickling fails with:"
- refactor:
McpErrorrenamed toMCPErrorand flatten parameters, Kludex, merged 2026-01-26; state: merged. - v2.0.0a1, published 2026-06-11; pre-release.
- v2.0.0, published 2026-07-28.
- PR merge compared with the first alpha; ahead, no commits behind.
- v1.29.0 compared with v2.0.0; includes the PR merge.
Checked
2026-11-24; read issue and comments API records, PR and changed exception implementation API records, alpha and stable release API records, release list and merge-to-tag comparisons; no command was run.
Started from a post by @rain87, packaged by the editor. Original post