Skip to content

Exception handling improvment #584

Closed Answered by stephentoub
fvdcx asked this question in Q&A
Discussion options

You must be logged in to vote

so the best way is to catch exception inside my tool?

Yes. If you want it sent down to the client as an error, you can return a CallToolResult out of your tool, with its IsError set to true.

Or you can catch your exception and wrap it in an McpException, which as you noted will then be special-cased to allow the message through.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by fvdcx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request
2 participants
Converted from issue

This discussion was converted from issue #577 on July 02, 2025 13:20.