Skip to content

Fix NODE_ENV=test preventing MCP server startup#17

Merged
Nek-12 merged 2 commits intomasterfrom
fix/node-env-detection
Nov 9, 2025
Merged

Fix NODE_ENV=test preventing MCP server startup#17
Nek-12 merged 2 commits intomasterfrom
fix/node-env-detection

Conversation

@Nek-12
Copy link
Member

@Nek-12 Nek-12 commented Nov 9, 2025

Fixes #16

Problem

When users spawn Claude programmatically and pass NODE_ENV=test in their environment, the MCP server fails to start. This is because the tool checks for NODE_ENV === 'test' to avoid running main() when imported during unit tests.

Solution

Restructured the codebase so tests don't import from index.ts anymore. The CLI entry point (index.ts) now has no exports and simply calls main() directly, eliminating the need for any test detection logic.

Changes

  • Separated concerns into 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 instead of index.js

  • Removed NODE_ENV check entirely from index.ts - now just calls main()

  • Added .mcpregistry_* to .gitignore

  • Improved 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

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
@Nek-12 Nek-12 enabled auto-merge November 9, 2025 15:28
@Nek-12 Nek-12 self-assigned this Nov 9, 2025
@Nek-12 Nek-12 merged commit 34ac5d4 into master Nov 9, 2025
3 checks passed
@Nek-12 Nek-12 deleted the fix/node-env-detection branch November 9, 2025 15:28
@Nek-12
Copy link
Member Author

Nek-12 commented Nov 9, 2025

@codex review

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.

[Suggestion] Emphasize the impact of NODE_ENV in the README.md

1 participant