Supergateway MCP Proxy
Supergateway is a command-line utility designed to bridge Model Context Protocol (MCP) stdio-based servers with network transports like Server-Sent Events (SSE), WebSockets (WS), and Streamable HTTP, and vice versa. It enables remote access, debugging, and client connectivity for MCP servers that primarily support stdio. The current stable version is 3.4.3. The project demonstrates a relatively active release cadence, with several minor updates and a significant rollback release (v3.4.0) to address stability issues from v3.3.0. Its key differentiator is providing a flexible gateway for various MCP communication patterns, facilitating integration of local stdio services into web-based or distributed systems. It supports both stateless and stateful operations for Streamable HTTP, and offers configurable concurrency for stdio-to-SSE gateways.
Common errors
-
Error: listen EADDRINUSE: address already in use :::8000
cause The default port 8000 (or another specified port) is already in use by another process on your system.fixSpecify an unused port using the `--port` flag (e.g., `npx supergateway --port 8001 ...`) or identify and terminate the process currently using the port. -
Connection refused
cause A client is unable to establish a connection with the Supergateway server, often because the server isn't running, is on a different address/port, or a firewall is blocking the connection.fixVerify that Supergateway is running, listening on the expected `--port` and `--baseUrl` (if specified). Check for any active firewalls or network configurations that might be preventing client connections. -
Error: Command 'your-stdio-command-here' not found
cause The command provided to the `--stdio` flag cannot be found or executed by the operating system.fixEnsure the command you pass to `--stdio` (e.g., `uvx mcp-server-git`, `node my-server.js`) is correctly spelled, executable, and present in your system's PATH. Test the command independently in your shell.
Warnings
- breaking Version 3.3.0 introduced significant stability issues related to concurrency improvements, causing some MCP stdio servers to hang. This version was explicitly rolled back in v3.4.0.
- gotcha Incorrect or omitted CORS configuration can prevent web clients from connecting due to cross-origin resource sharing policies.
- gotcha Concurrency settings (`--minConcurrency`, `--maxConcurrency`) for stdio-to-SSE mode, while offering performance benefits, can introduce stability issues if not correctly tuned for your specific MCP server.
- gotcha When connecting to remote SSE or Streamable HTTP servers that require authentication, forgetting to pass appropriate headers will result in unauthorized access or connection failures.
Install
-
npm install supergateway -
yarn add supergateway -
pnpm add supergateway
Imports
- supergateway CLI (stdio to SSE/WS)
import { Supergateway } from 'supergateway'npx supergateway --stdio "your-mcp-command" --port 8000
- supergateway CLI (SSE to stdio)
const gateway = require('supergateway'); gateway.connectSSE(...)npx supergateway --sse "https://remote-mcp-server.example.com"
- supergateway CLI (Streamable HTTP to stdio)
npm install supergateway && node_modules/supergateway/cli.js --streamableHttp ...
npx supergateway --streamableHttp "https://remote-mcp-server.example.com/mcp"
Quickstart
const { exec } = require('child_process');
// This command starts Supergateway, which in turn runs an MCP server
// (here, a filesystem-based one) and exposes its communication
// via SSE endpoints on localhost:8000.
//
// Clients can then subscribe to events via GET /sse and send messages
// via POST /message to interact with the underlying stdio server.
// Replace 'npx -y @modelcontextprotocol/server-filesystem ./my-folder'
// with your actual MCP stdio server command.
const supergatewayCommand = `npx -y supergateway \n --stdio "npx -y @modelcontextprotocol/server-filesystem ./my-folder" \n --port 8000 --baseUrl http://localhost:8000 \n --ssePath /sse --messagePath /message`;
console.log("To start Supergateway, run this in your terminal:");
console.log(supergatewayCommand);
// Example of how you might programmatically run it in a Node.js script
// (though Supergateway is typically run directly in a shell)
// exec(supergatewayCommand, (error, stdout, stderr) => {
// if (error) {
// console.error(`exec error: ${error}`);
// return;
// }
// console.log(`stdout: ${stdout}`);
// console.error(`stderr: ${stderr}`);
// });
console.log("\nOnce running, you can subscribe to events with: GET http://localhost:8000/sse");
console.log("And send messages with: POST http://localhost:8000/message");