Skip to content

fix: resolve .env path with fallback chain (#16)#17

Open
bvisible wants to merge 1 commit intomainfrom
fix/env-path-resolution
Open

fix: resolve .env path with fallback chain (#16)#17
bvisible wants to merge 1 commit intomainfrom
fix/env-path-resolution

Conversation

@bvisible
Copy link
Copy Markdown
Owner

Summary

Fixes #16 — SSH servers not loaded when installed globally via npm.

  • .env path resolution: Replace hardcoded __dirname/../.env with a fallback chain: SSH_ENV_PATH env var → cwd/.env~/.env__dirname/../.env
  • Race condition fix: configLoader.load(), initializeHooks(), and loadToolConfig() are now properly awaited instead of using fire-and-forget .then(), ensuring config is fully loaded before the MCP server starts responding
  • Debug logging: The resolved envFilePath is now logged at startup for easier troubleshooting

Test plan

  • Global npm install: verify .env in ~ is found
  • Local clone: verify .env in project root is still found (backward compat)
  • SSH_ENV_PATH=/custom/path/.env: verify explicit override works
  • Verify no race condition: server list is populated before first tool call

…name (#16)

The .env path was hardcoded to __dirname/../.env which points inside
node_modules for global npm installs, so servers were never found.

Now searches: SSH_ENV_PATH env var → cwd/.env → ~/.env → __dirname/../.env

Also awaits configLoader.load(), initializeHooks() and loadToolConfig()
to fix race condition where MCP server started before config was loaded.
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.

SSH servers not loaded — hardcoded __dirname path ignores process.cwd()

1 participant