modelcontextprotocol / modelcontextprotocol/python-sdk
raise without from discards exception chain in 12 remaining sites
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.3k
- Forks
- 4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 31
Description
Initial Checks
- I confirm that I'm using the latest version of MCP Python SDK
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Description
Follow-up to #2541 (fixed in #2542). The same pattern exists in 12 additional sites across 7 files. Each catches an exception and re-raises a new one without from, discarding the original traceback and __cause__.
Sites:
| File | Line | Caught | Raised |
|---|---|---|---|
client/session.py |
346 | ValidationError |
RuntimeError |
client/session.py |
348 | SchemaError |
RuntimeError |
client/auth/utils.py |
246 | ValidationError |
OAuthRegistrationError |
client/auth/utils.py |
339 | ValidationError |
OAuthTokenError |
server/auth/middleware/client_auth.py |
83 | ValueError/UnicodeDecodeError/binascii.Error |
AuthenticationError |
server/mcpserver/resources/types.py |
75 | Exception |
ValueError |
server/mcpserver/resources/types.py |
151 | Exception |
ValueError |
server/mcpserver/resources/types.py |
196 | Exception |
ValueError |
server/mcpserver/resources/types.py |
205 | Exception |
ValueError |
server/mcpserver/resources/resource_manager.py |
96 | Exception |
ValueError |
server/mcpserver/resources/templates.py |
133 | Exception |
ValueError |
server/mcpserver/prompts/base.py |
185, 189 | Exception |
ValueError |
Impact
Same as #2541: without from, Python shows "During handling of the above exception, another exception occurred" instead of "The above exception was the direct cause of the following exception." Callers cannot inspect __cause__ to determine the root cause programmatically.
The codebase already uses from correctly in server.py:451, server.py:459, server.py:1112, func_metadata.py:216,265, and tools/base.py:119. These 12 sites are the remaining inconsistencies.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the 12 listed sites in client/session.py, client/auth/utils.py, server/auth/middleware/client_auth.py, server/mcpserver/resources/types.py, resource_manager.py, templates.py, and prompts/base.py. Compare them with the existing uses in server.py, func_metadata.py, and tools/base.py. Done means each re-raised exception preserves the original as its direct cause and the relevant client and server behavior remains passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100