Skip to content

Conversation

@jacksteamdev
Copy link
Contributor

@jacksteamdev jacksteamdev commented Dec 17, 2024

Motivation and Context

spawn-rx follows symlinks when resolving executables, which breaks version manager shims on macOS. For example, when using Volta, bun incorrectly resolves to volta-shim instead of the bun executable. This PR works around the issue by bypassing spawn-rx's path resolution on non-Windows platforms.

Closes #114

How Has This Been Tested?

  • Verified direct command execution works with Volta-managed bun on macOS
  • Confirmed Windows path resolution remains untouched

Breaking Changes

None. This restores expected behavior on macOS while maintaining existing Windows functionality.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

This could be a temporary fix while we investigate the underlying spawn-rx path resolution behavior. We may want to upstream a fix that handles Windows PATH resolution without affecting Unix shims.

To Reproduce

Steps to reproduce the behavior:

  1. On MacOS, use Volta or another Node version management tool that uses symlinks to install Node or Bun.
  2. In the MPC inspector UI, enter your command: bun or node.
  3. Use the MPC inspector to launch your server.
image

Expected behavior

The inspector should spawn the command as entered in the UI.

Logs

I'm getting this error:

Volta error: 'volta-shim' should not be called directly. Please use the existing shims provided by Volta (node, yarn, etc.) to run tools.

Note that the command bun is resolved incorrectly.

Stdio transport: command=/Users/jacksteam/.volta/bin/volta-shim, args=src/index.ts, env={"HOME":"/Users/jacksteam","LOGNAME":"jacksteam","PATH":"/Users/jacksteam/.npm/_npx/5a9d879542beca3a/node_modules/.bin:/Users/jacksteam/Documents/Cline/MCP/zettelkasten-server/node_modules/.bin:/Users/jacksteam/Documents/Cline/MCP/node_modules/.bin:/Users/jacksteam/Documents/Cline/node_modules/.bin:/Users/jacksteam/Documents/node_modules/.bin:/Users/jacksteam/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/Users/jacksteam/.volta/tools/image/node/20.16.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/Users/jacksteam/.volta/tools/image/node/20.16.0/bin:/Users/jacksteam/perl5/bin:/Users/jacksteam/Library/pnpm:/Users/jacksteam/.volta/bin:/opt/homebrew/opt/openjdk/bin:/Users/jacksteam/.jenv/shims:/Users/jacksteam/.jenv/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/jacksteam/Library/Application Support/Code/User/globalStorage/github.copilot-chat/debugCommand","SHELL":"/bin/zsh","TERM":"xterm-256color","USER":"jacksteam"}

Edit: rephrase to be more clear and concise, add additional context

@anaisbetts
Copy link
Contributor

Can you explain more about what is going on with spawn-rx? I'd rather actually just make it work correctly on all platforms

@jacksteamdev
Copy link
Contributor Author

jacksteamdev commented Dec 19, 2024

@anaisbetts Hi Ani! Looking at spawn-rx, I think I've identified the core issue: runDownPath follows symlinks with realpathSync, which breaks version manager shims on macOS.

For example with Volta-managed bun:

  • which bun/Users/jacksteam/.volta/bin/bun
  • runDownPath("bun")/Users/jacksteam/.volta/bin/volta-shim

The code comment suggests this was added for Windows PATH resolution. Would you mind sharing the original Windows issue this was solving? We might be able to handle that case specifically while preserving normal PATH behavior on Unix.


Edit: rephrase to be more concise

@jacksteamdev jacksteamdev changed the title fix(server) Differentiate command resolution by platform fix(server) Avoid modifying path resolution for executables on MacOS Dec 19, 2024
@jacksteamdev
Copy link
Contributor Author

Hi @anaisbetts, hope you had a nice holiday break! Just wanted to follow up on this PR - would you have time to take another look when you get a chance?

@anaisbetts
Copy link
Contributor

anaisbetts commented Feb 10, 2025

@jacksteamdev Update spawn-rx to v5.1.2 in this PR instead and this should be fixed

@jacksteamdev
Copy link
Contributor Author

Thanks @anaisbetts! It works a treat.

Copy link
Member

@jspahrsummers jspahrsummers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jspahrsummers jspahrsummers merged commit d4df126 into modelcontextprotocol:main Feb 19, 2025
2 checks passed
IgnacioC44 referenced this pull request in MCPJam/inspector Jun 21, 2025
fix(server) Avoid modifying path resolution for executables on MacOS
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.

Path resolution library doesn't handle MacOS commands correctly

3 participants