Improve error handling to use MCP tool-level errors#55
Merged
wesleyjellis merged 1 commit intomainfrom Jun 12, 2025
Merged
Conversation
…tegration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull Request Overview
This PR improves error handling by wrapping native errors into MCP tool-level errors for consistent CLI responses.
- Updates
newToolResultto returnCallToolResulterror objects instead of raw errors - Replaces direct
nil, errreturns in Cobra commands withmcp.NewToolResultErrorormcp.NewToolResultErrorFromErr - Adds explicit parameter-required error messages for
req.RequireStringcalls
Comments suppressed due to low confidence (2)
src/cmd/root.go:97
- [nitpick] The error message "operation failed" is very generic; consider adding context about which operation failed or using a more descriptive message.
return mcp.NewToolResultErrorFromErr("operation failed", err), nil
src/cmd/root.go:94
- Add unit tests for
newToolResultto verify both success and error branches produce the expectedCallToolResultinstances with correct error wrapping.
func newToolResult(obj any, err error) (*mcp.CallToolResult, error) {
derek-etherton-opslevel
approved these changes
Jun 12, 2025
Contributor
derek-etherton-opslevel
left a comment
There was a problem hiding this comment.
makes sense to me, thanks for the QoL improvements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Generated with Claude Code
Problem
I noticed sometimes we return
nilwhen something goes wrong, but there's a specific error response we can (and I think should) useSolution
Checklist