Initial Checks
Description
In server/mcpserver/server.py, the get_prompt handler catches all exceptions and re-raises as ValueError(str(e)) without chaining:
Line 1110-1112:
except Exception as e:
logger.exception(f"Error getting prompt {name}")
raise ValueError(str(e))
This discards the original exception's type, traceback, and identity. Callers cannot use isinstance() or __cause__ to determine what went wrong.
The same file uses the correct pattern eight lines earlier (line 459):
raise ResourceError(f"Error reading resource {uri}") from exc
A second instance at line 451 also omits from:
except ValueError:
raise ResourceError(f"Unknown resource: {uri}")
Fix
# Line 1112
raise ValueError(str(e)) from e
# Line 451
except ValueError as exc:
raise ResourceError(f"Unknown resource: {uri}") from exc
Impact
Without 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.
Initial Checks
Description
In
server/mcpserver/server.py, theget_prompthandler catches all exceptions and re-raises asValueError(str(e))without chaining:Line 1110-1112:
This discards the original exception's type, traceback, and identity. Callers cannot use
isinstance()or__cause__to determine what went wrong.The same file uses the correct pattern eight lines earlier (line 459):
A second instance at line 451 also omits
from:Fix
Impact
Without
from, Python shows "During handling of the above exception, another exception occurred" which is confusing. Withfrom, it shows "The above exception was the direct cause of the following exception" and preserves__cause__for programmatic inspection.