Skip to content

Conversation

@yubingjiaocn
Copy link
Contributor

@yubingjiaocn yubingjiaocn commented Jun 22, 2025

Summary

Fixes timeout issues when proxying Node.js MCP servers with arguments that start with -.

Close #22

Problem

Commands like npx mcp-proxy --shell npx -- -y @modelcontextprotocol/server-everything were failing with timeout errors because yargs argument parsing didn't properly handle the -- separator.

Solution

  • Add preprocessing to detect and handle -- separator in process.argv
  • Split arguments into mcp-proxy options (before --) and target command args (after --)
  • Preserve backward compatibility for commands without -- separator
  • Maintain original behavior where command comes from yargs and everything after -- becomes arguments

Test Results

Both formats now work correctly:

  • Without --: npx mcp-proxy --shell npx @modelcontextprotocol/server-everything
  • With --: npx mcp-proxy --shell npx -- -y @modelcontextprotocol/server-everything

Tested with @modelcontextprotocol/server-everything - no more timeout errors, successful MCP handshake and server startup.

Backward Compatibility

✅ All existing functionality preserved
✅ All existing tests pass
✅ No breaking changes

🤖 Generated with Claude Code

@punkpeye
Copy link
Owner

I believe you are looking for https://github.com/yargs/yargs-parser?tab=readme-ov-file#populate---

@yubingjiaocn
Copy link
Contributor Author

Hi, I updated my implementation with you recommended method. Please review. Thx.

@punkpeye
Copy link
Owner

Please undo unrelated changes.

@yubingjiaocn
Copy link
Contributor Author

@punkpeye Reverted.

@punkpeye punkpeye merged commit 091426b into punkpeye:main Jul 1, 2025
1 check passed
@punkpeye
Copy link
Owner

punkpeye commented Jul 1, 2025

Thank you

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.

Unable to proxy nodejs-based MCP server

2 participants