mcp2websocket v2.0.0 bridges MCP stdio clients to WebSocket-based MCP servers, translating JSON-RPC messages between the two transports. It provides automatic reconnection with exponential backoff, message queuing during disconnects, heartbeat/ping-pong for health checks, and optional debug logging to stderr. Unlike raw WebSocket clients, it handles the full lifecycle: graceful shutdown, connection management, and compatibility with MCP client configs (e.g., Claude Desktop). Requires Node >=14. Package is stable with infrequent releases.
npm install mcp2websocketNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initializes a bridge from stdio to a WebSocket MCP server with authentication and debug flags, including graceful shutdown.
Add "type": "module" to package.json or use dynamic import: const pkg = await import('mcp2websocket')Run as: mcp2websocket ws://example.com/mcp
Use --debug flag or DEBUG=true env var; logs appear on stderr only.
Pass --token your-token or set AUTH_TOKEN environment variable.
Monitor memory usage; consider implementing backpressure in your MCP client if messages are produced faster than the server can consume.
Switch to ESM: set "type": "module" in package.json, rename .js to .mjs, or use dynamic import: const pkg = await import('mcp2websocket')Ensure --debug flag or DEBUG env var is not set when running in production; logs only appear on stderr.
Validate that the server sends valid JSON-RPC messages (must contain jsonrpc, id, method, etc.). Check WebSocket server logs.
Verify the WebSocket server is started and reachable at the given URL. Check firewall/network settings.