Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SDK work on Windows without additional arguments #101

Open
JonasHelming opened this issue Dec 19, 2024 · 1 comment
Open

Make SDK work on Windows without additional arguments #101

JonasHelming opened this issue Dec 19, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@JonasHelming
Copy link

Is your feature request related to a problem? Please describe.
We experienced that to start MCP servers via the SDK on Windows, you need to start a command interpreter (e.g. cmd.exe) as the server command in order for path lookups to work as expected
e.g. like this:

"filesystem": {
    "command": "cmd",
    "args": ["/C", "npx -y @modelcontextprotocol/server-filesystem /Users/YOUR_USERNAME/Desktop"],
    "env": {
      "CUSTOM_ENV_VAR": "custom-value"
    }
  }

Describe the solution you'd like

Would be nice to hide this in the client SDK to hide the complexity from the user, at least with a sensible default for Windows.

Describe alternatives you've considered
none

Additional context
We have documented this work around for our users: https://theia-ide.org/docs/user_ai/#mcp-integration
See also: https://eclipsesource.com/blogs/2024/12/19/theia-ide-and-theia-ai-support-mcp/

@JonasHelming JonasHelming added the enhancement New feature or request label Dec 19, 2024
@aiqlcom
Copy link

aiqlcom commented Dec 21, 2024

I also encounter the same issue, and I noticed that there is an ongoing pull request addressing it: #95

This pull request aims to replace spawn with cross-spawn to resolve the issue.

ad6ea75#diff-cf9cf0e16fe93b95e6cc378c616f4cf5e884677337106dec23f740caee8707c3R1-R2

My workaround:

I am currently employing an alternative method as a temporary workaround to address this issue:

return new Promise((resolve, reject) => {
this._process = spawn(
this._serverParams.command,
this._serverParams.args ?? [],
{
env: this._serverParams.env ?? getDefaultEnvironment(),
stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
shell: false,
signal: this._abortController.signal,
windowsHide: process.platform === "win32" && isElectron(),
}
);

On Linux or macOS, shell: true is usually not required because command-line tools (such as npx) are typically standalone executables.

However, on Windows, shell: true is necessary to ensure that commands are executed correctly through the command interpreter.

Thus, I replaced it with shell: process.platform === "win32" ? true : false to temporarily avoid this issue.

@jspahrsummers jspahrsummers added bug Something isn't working and removed enhancement New feature or request labels Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants