Title: raise ValueError(str(e)) discards exception chain in get_prompt handler · Issue #2541 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: raise ValueError(str(e)) discards exception chain in get_prompt handler · Issue #2541 · modelcontextprotocol/python-sdk
X Title: raise ValueError(str(e)) discards exception chain in get_prompt handler · Issue #2541 · modelcontextprotocol/python-sdk
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 In server/mcpserver/se...
Open Graph 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 ...
X 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 t...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/2541
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"raise ValueError(str(e)) discards exception chain in get_prompt handler","articleBody":"### Initial Checks\n\n- [x] I confirm that I'm using the latest version of MCP Python SDK\n- [x] I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue\n\n### Description\n\nIn `server/mcpserver/server.py`, the `get_prompt` handler catches all exceptions and re-raises as `ValueError(str(e))` without chaining:\n\n**Line 1110-1112:**\n```python\nexcept Exception as e:\n logger.exception(f\"Error getting prompt {name}\")\n raise ValueError(str(e))\n```\n\nThis discards the original exception's type, traceback, and identity. Callers cannot use `isinstance()` or `__cause__` to determine what went wrong.\n\nThe same file uses the correct pattern eight lines earlier (line 459):\n```python\nraise ResourceError(f\"Error reading resource {uri}\") from exc\n```\n\nA second instance at line 451 also omits `from`:\n```python\nexcept ValueError:\n raise ResourceError(f\"Unknown resource: {uri}\")\n```\n\n### Fix\n\n```python\n# Line 1112\nraise ValueError(str(e)) from e\n\n# Line 451\nexcept ValueError as exc:\n raise ResourceError(f\"Unknown resource: {uri}\") from exc\n```\n\n### Impact\n\nWithout `from`, Python shows \"During handling of the above exception, another exception occurred\" which is confusing. With `from`, it shows \"The above exception was the direct cause of the following exception\" and preserves `__cause__` for programmatic inspection.","author":{"url":"https://github.com/blackwell-systems","@type":"Person","name":"blackwell-systems"},"datePublished":"2026-05-05T01:52:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/2541/python-sdk/issues/2541"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5955851c-dc68-a266-c9da-f2da2a5a7541 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9698:96B0A:21448D6:2C98A9E:6A59973E |
| html-safe-nonce | bb6e04b0b4adfb9030ece9614ce3e4b1030daff2868ab6fdd8768de8ea3583aa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Njk4Ojk2QjBBOjIxNDQ4RDY6MkM5OEE5RTo2QTU5OTczRSIsInZpc2l0b3JfaWQiOiIzODIzMjAyMDQyNjc3NjYzNTUwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 82d26d9340e12f57902e543c703d900c9c4d509745d3e7759a500f465bdd48bd |
| hovercard-subject-tag | issue:4380923060 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/2541/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ed375e7ba6e9377575ee43e4109a443a38925f027d32f694ec4be5399d3d0274/modelcontextprotocol/python-sdk/issues/2541 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ed375e7ba6e9377575ee43e4109a443a38925f027d32f694ec4be5399d3d0274/modelcontextprotocol/python-sdk/issues/2541 |
| og:image:alt | 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 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | blackwell-systems |
| hostname | github.com |
| expected-hostname | github.com |
| None | a540949572872b935b393b36db38922db390ae71c859537d741b8f3eb7e545b5 |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 737e0bf019c29d8431b268ae84d528b052789210 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width