Skip to content

fix: improve McpDocsServer concurrency, lifecycle, and error handling#26

Merged
scalvert merged 1 commit into
mainfrom
sc/fix-server-concurrency
Apr 12, 2026
Merged

fix: improve McpDocsServer concurrency, lifecycle, and error handling#26
scalvert merged 1 commit into
mainfrom
sc/fix-server-concurrency

Conversation

@scalvert

Copy link
Copy Markdown
Owner

Summary

  • Replace initialized boolean with promise-based lock to prevent race conditions when concurrent requests trigger initialization
  • Create a new McpServer per request instead of reusing a singleton, preventing transport overwriting under concurrent load
  • Cache initialization failures so subsequent requests get immediate errors instead of retrying doomed I/O
  • Fix getStatus() to use SearchProvider.getDocCount() instead of instanceof FlexSearchProvider, preserving the provider abstraction
  • Sanitize error messages in MCP tool handlers to prevent leaking internal details to clients

Test plan

  • npm run build passes
  • npm run typecheck passes
  • npm test passes

Closes #15

🤖 Generated with Claude Code

- Replace initialized boolean with promise-based lock to prevent race
  conditions when concurrent requests trigger initialization
- Create a new McpServer per request instead of reusing a singleton,
  preventing transport overwriting under concurrent load
- Cache initialization failures so subsequent requests get immediate
  errors instead of retrying doomed I/O
- Fix getStatus() to use SearchProvider.getDocCount() instead of
  instanceof FlexSearchProvider, preserving the provider abstraction
- Sanitize error messages in MCP tool handlers to prevent leaking
  internal details to clients

Closes #15

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@scalvert scalvert added the bug Something isn't working label Apr 12, 2026
@scalvert
scalvert merged commit d9f5f99 into main Apr 12, 2026
8 checks passed
@scalvert
scalvert deleted the sc/fix-server-concurrency branch April 12, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix McpDocsServer concurrency, lifecycle, and provider abstraction

1 participant