Skip to content

[Client] Start stdio servers whose command path has a space - #766

Closed
ajibarra wants to merge 1 commit into
modelcontextprotocol:mainfrom
ajibarra:fix/stdio-command-path
Closed

ajibarra wants to merge 1 commit into
modelcontextprotocol:mainfrom
ajibarra:fix/stdio-command-path

Conversation

@ajibarra

Copy link
Copy Markdown

StdioTransport built a shell line with escapeshellcmd(), which leaves spaces alone, so a command whose path has one (/Users/me/My Tools/server, C:\Program Files\...) never started. It now hands the command and its arguments to proc_open() as an array, which starts the program without a shell on every platform; a command that relied on the shell to split arguments ('npx -y pkg') has to pass them in args, which the changelog lists as a [BC Break].

@soyuka

soyuka commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Thanks, but I think this already works by quoting the path, escapeshellcmd() keeps paired quotes:

new StdioTransport('"/Users/me/My Tools/server"', [...]);

On Windows the command is already passed as an array so spaces are fine. Not worth a BC break on 'npx -y pkg' imo, closing, feel free to open a docs PR mentioning the quoting though.

@soyuka soyuka closed this Nov 26, 2026
@ajibarra

Copy link
Copy Markdown
Author

Fair enough, quoting does work for plain spaces. One case it doesn't cover: escapeshellcmd() still backslashes (, ), &, $ and the like inside paired quotes, and sh keeps those backslashes inside double quotes, so '"/Users/me/Tools (old)/server"' fails with "No such file or directory". Starting it through env with the path as an argument works for those. I'll send the docs PR with the quoting tip and that caveat.

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.

2 participants