fix(tools): add startup resilience and request timeout for API calls (fix #84, fix #85)#86
Open
aosmcleod wants to merge 1 commit into
Open
Conversation
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.
Closes #84, #85
Description
Two resilience issues in the MCP server startup and tool execution:
1. Server crashes if API is unreachable at startup (#84)
initializeToolscallsgetSharedContext()without error handling. If the HeroUI API is down (network issue, DNS failure, maintenance), the entire MCP server crashes withprocess.exit(1).Fix: Wrap
getSharedContextin a try/catch with a fallback empty context ({ componentList: [] }). The server starts with degraded functionality — tools that need the component list will report errors per-call rather than preventing the server from starting entirely.2. API calls have no timeout — can hang indefinitely (#85)
The shared context fetch (and by extension, tool API calls) use
fetch()without anAbortController. If the API hangs, the MCP server hangs forever.Fix: Add a 30-second
AbortControllertimeout to the shared context fetch. The timeout is configurable via theDEFAULT_FETCH_TIMEOUT_MSconstant.Current behavior
New behavior
Is this a breaking change:
No — the server is strictly more resilient. Tools that previously worked continue to work identically.