refactor(mcp): convert handlers to Result-based error handling#282
Open
galligan wants to merge 1 commit into
Open
refactor(mcp): convert handlers to Result-based error handling#282galligan wants to merge 1 commit into
galligan wants to merge 1 commit into
Conversation
This was referenced Feb 22, 2026
Contributor
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Replace all throw statements in MCP handler and utility files with Result<T, OutfitterError> return types. Security-boundary throws in filesystem.ts are converted to ValidationError results propagated through callers. Tests updated from rejects.toThrow() to isErr() checks. 🤘🏻 In-collaboration-with: [Claude Code](https://claude.com/claude-code)
0729c5f to
c484757
Compare
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.

Replace all throw statements in MCP handler and utility files with
Result<T, OutfitterError> return types. Security-boundary throws in
filesystem.ts are converted to ValidationError results propagated
through callers. Tests updated from rejects.toThrow() to isErr() checks.
🤘🏻 In-collaboration-with: Claude Code
Greptile Summary
Systematically converts all MCP handler and utility functions from throwing exceptions to returning
Result<T, OutfitterError>. Security-boundary path validation infilesystem.tsnow returnsValidationErrorinstead of throwing, with errors propagated through all callers. Tests comprehensively updated fromrejects.toThrow()toisErr()assertions.Key changes:
safeParse()returningValidationErroron failureNotFoundErrorfor missing filesInternalErrorValidationErrorresources/index.tsunwraps Results and throws for protocol complianceConfidence Score: 5/5
Important Files Changed
collectRecords()andexpandInputPaths()Result<ToolContent, OutfitterError>, wrapping help action inResult.ok()Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[MCP Client Request] --> B[SDK Server Handler] B --> C{Tool or Resource?} C -->|Tool| D[handleWaymarkTool] C -->|Resource| E[handleTodosResource] D --> F{Action Type} F -->|scan| G[handleScan] F -->|graph| H[handleGraph] F -->|add| I[handleAdd] F -->|help| J[handleHelp] G --> K[collectRecords] H --> K I --> K E --> K K --> L[expandInputPaths] L --> M{Path valid?} M -->|No| N[Result.err ValidationError] M -->|Yes| O[collectFilesRecursive] O --> P{Escapes workspace?} P -->|Yes| N P -->|No| Q[Result.ok files] I --> R[Input Validation] R --> S{Valid?} S -->|No| T[Result.err ValidationError] S -->|Yes| U[Process & Write] U --> V[Result.ok ToolContent] J --> V Q --> V N --> W[SDK Boundary] T --> W V --> W W --> X{isErr?} X -->|Yes| Y[throw Error] X -->|No| Z[Return Value] Y --> AA[MCP Error Response] Z --> AB[MCP Success Response]Last reviewed commit: c484757