Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

eiriktsarpalis
Copy link
Member

Fix #594.

@eiriktsarpalis
Copy link
Member Author

cc @jozkee

string id = Guid.NewGuid().ToString("N");

StdioClientTransport transport = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
new(new() { Command = "cmd", Arguments = ["/C", $"echo \"{id}\" >&2"] }, LoggerFactory) :
Copy link
Member Author

Choose a reason for hiding this comment

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

@PederHP @jeffhandley A side effect of this change is that inserting shell pipe syntax in the CLI arguments is no longer possible. I think this is ok given it's a Windows-specific quirk, but I thought I'd double check.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just some ideas, we could:

  • Not change the behavior and defer to users the escaping of characters like &, we could also augment the remarks around StdioClientTransportOptions.Arguments.
  • Use Arguments instead of ArgumentList, but that requires implementing our own escaping, basically a copy of PasteArguments that wraps the argument in quotes if it contains &.

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.

MCP - StdioClientTransport doesn't handle ampersands ("&") as arguments to cmd.exe
3 participants