fix: add error handling to 8 tools with unguarded async handlers - #221
Open
TerminalGravity wants to merge 1 commit into
Open
fix: add error handling to 8 tools with unguarded async handlers#221TerminalGravity wants to merge 1 commit into
TerminalGravity wants to merge 1 commit into
Conversation
Tools that previously had no try/catch and would crash on errors (e.g., git not available, corrupt state files, missing dirs) now return user-friendly error messages instead of throwing: - audit_workspace - check_patterns - checkpoint - search_contracts - sequence_tasks - session_health - sharpen_followup - what_changed
TerminalGravity
commented
Mar 11, 2026
TerminalGravity
left a comment
Collaborator
Author
There was a problem hiding this comment.
Good defensive addition. The try/catch wrappers ensure MCP tools return error content instead of crashing the server process.
One concern: this PR still uses the broken run() calls (e.g., what-changed.ts line 13 still has run(\git diff ...`)`). This should be rebased on top of #220 after it merges, otherwise you're wrapping error handlers around calls that silently fail anyway.
Also, the pattern could be DRY'd with a wrapper:
function safeTool(fn: () => Promise<ToolResult>): Promise<ToolResult> {
try { return await fn(); }
catch (err) { return { content: [{ type: 'text', text: \`❌ \${err}\` }] }; }
}Not blocking, but worth considering to avoid the indent creep across 8 files.
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.
8 tools had no try/catch around their async handlers. If git wasn't available, state files were corrupt, or directories were missing, they'd throw unhandled errors and crash the MCP server.
Now they return user-friendly error messages (e.g.
❌ checkpoint failed: ...) instead of crashing.Tools fixed: audit_workspace, check_patterns, checkpoint, search_contracts, sequence_tasks, session_health, sharpen_followup, what_changed