Fix NODE_ENV=test preventing MCP server startup#17
Merged
Conversation
Fixes #16 When users spawn Claude programmatically and pass NODE_ENV=test in their environment, the MCP server would fail to start due to test detection logic that skipped main() execution. Changes: - Restructured codebase to separate concerns into modules - Tests no longer import from index.ts (the CLI entry point) - Removed NODE_ENV check entirely - index.ts now just calls main() - Created new modules: * src/cli-args.ts - CLI argument parsing * src/client.ts - Upstream client creation * src/config.ts - Proxy configuration * src/utils/env-parser.ts - Environment variable parsing * src/utils/tool-list-formatter.ts - Tool list formatting - Updated all test imports to use the new modules - Added .mcpregistry_* and publish.sh to .gitignore - Improved CI workflow with final status check job
- Fixed moderate severity vulnerability in vite (7.1.0 -> 7.1.11) - Updated all other dependencies to latest compatible versions - All 200 tests passing
Member
Author
|
@codex review |
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.
Fixes #16
Problem
When users spawn Claude programmatically and pass
NODE_ENV=testin their environment, the MCP server fails to start. This is because the tool checks forNODE_ENV === 'test'to avoid runningmain()when imported during unit tests.Solution
Restructured the codebase so tests don't import from
index.tsanymore. The CLI entry point (index.ts) now has no exports and simply callsmain()directly, eliminating the need for any test detection logic.Changes
Separated concerns into modules:
src/cli-args.ts- CLI argument parsingsrc/client.ts- Upstream client creationsrc/config.ts- Proxy configurationsrc/utils/env-parser.ts- Environment variable parsingsrc/utils/tool-list-formatter.ts- Tool list formattingUpdated all test imports to use the new modules instead of
index.jsRemoved NODE_ENV check entirely from
index.ts- now just callsmain()Added
.mcpregistry_*to.gitignoreImproved CI workflow with final status check job
Test Results
All 200 tests passing ✓
Breaking Changes
None - this is a refactoring that maintains all existing functionality