Skip to content

fix(tools): add startup resilience and request timeout for API calls (fix #84, fix #85)#86

Open
aosmcleod wants to merge 1 commit into
heroui-inc:developfrom
aosmcleod:fix/mcp-startup-resilience
Open

fix(tools): add startup resilience and request timeout for API calls (fix #84, fix #85)#86
aosmcleod wants to merge 1 commit into
heroui-inc:developfrom
aosmcleod:fix/mcp-startup-resilience

Conversation

@aosmcleod

Copy link
Copy Markdown

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)

initializeTools calls getSharedContext() without error handling. If the HeroUI API is down (network issue, DNS failure, maintenance), the entire MCP server crashes with process.exit(1).

Fix: Wrap getSharedContext in 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 an AbortController. If the API hangs, the MCP server hangs forever.

Fix: Add a 30-second AbortController timeout to the shared context fetch. The timeout is configurable via the DEFAULT_FETCH_TIMEOUT_MS constant.

Current behavior

  • API unreachable at startup → server crashes, AI assistant reports "MCP server failed to start"
  • API hangs → MCP tool call blocks indefinitely, conversation appears frozen

New behavior

  • API unreachable at startup → server starts with warning, tools report errors individually
  • API hangs → request aborts after 30s with a clear timeout error message

Is this a breaking change:

No — the server is strictly more resilient. Tools that previously worked continue to work identically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] - MCP server crashes if API is unreachable at startup — no graceful degradation

1 participant