← 开源

Run MCP stdio servers over HTTP streamable, SSE and SSE over stdio. AI gateway.

InfrastructureGatewayTypeScript
增长势头
+224 小时新增 Star+0.1%
3.01k
Star
272
Fork
+17
本周
10
贡献者
创建于 2024-12-21 · 更新于 2026-12-06 · 今日第 3829 名
主要开发者
README

Supergateway runs MCP stdio-based servers over SSE (Server-Sent Events) or WebSockets (WS) with one command. This is useful for remote access, debugging, or connecting to clients when your MCP server only supports stdio.

Questions, ideas or just want to chat? Join the community on Discord.

Supported by:

Installation & Usage

Run Supergateway via npx:

npx -y supergateway --stdio "uvx mcp-server-git"
  • --stdio "command": Command that runs an MCP server over stdio

  • --sse "https://mcp-server-ab71a6b2-cd55-49d0-adba-562bc85956e3.supermachine.app": SSE URL to connect to (SSE→stdio mode)

  • --streamableHttp "https://mcp-server.example.com/mcp": Streamable HTTP URL to connect to (StreamableHttp→stdio mode)

  • --outputTransport stdio | sse | ws | streamableHttp: Output MCP transport (default: sse with --stdio, stdio with --sse or --streamableHttp). A remote server given with --sse or --streamableHttp can be served over sse, ws or streamableHttp too; see Remote server → SSE, WS or Streamable HTTP

  • --port 8000: Port to listen on (stdio→SSE, stdio→WS or stdio→Streamable HTTP mode, default: 8000)

  • --host 127.0.0.1: Address to listen on, e.g. 127.0.0.1 or ::1 ([::1] also works) (stdio→SSE, stdio→WS or stdio→Streamable HTTP mode, default: every interface). --baseUrl does not control binding: only --host limits which addresses accept connections. Refused in SSE→stdio and Streamable HTTP→stdio mode, which listen on nothing

  • --baseUrl "http://localhost:8000": Base URL for SSE clients (stdio→SSE mode; optional)

  • --ssePath "/sse": Path for SSE subscriptions (stdio→SSE mode, default: /sse)

  • --messagePath "/message": Path for messages (stdio→SSE or stdio→WS mode, default: /message)

  • --streamableHttpPath "/mcp": Path for Streamable HTTP (stdio→Streamable HTTP mode, default: /mcp)

  • --stateful: Run stdio→Streamable HTTP in stateful mode

  • --sessionTimeout 60000: Session timeout in milliseconds (stateful stdio→Streamable HTTP mode only)

  • --protocolVersion "2025-06-18": Protocol version the gateway uses when it initializes the server itself and the client's request doesn't name one (stateless stdio→Streamable HTTP mode, default: 2024-11-05)

  • --header "x-user-id: 123": Add one or more headers (stdio→SSE, stdio→Streamable HTTP, SSE→stdio, or Streamable HTTP→stdio mode; can be used multiple times). With a local server they go on the gateway's responses; with a remote one (--sse, --streamableHttp) they are sent to the remote server

  • --oauth2Bearer "some-access-token": Adds an Authorization header with the provided Bearer token

  • --logLevel debug | info | none: Controls logging level (default: info). Use debug for more verbose logs, none to suppress all logs except the startup warnings.

  • --logFormat text | json: Log line format (default: text). json writes one JSON object per line with time, level, msg and, when a log call carries values, data, for ELK and similar log pipelines. Logs go to the same streams as text, so stdio output still carries only MCP messages. Once the port is open, the line with "event": "listening" gives the bound port and each server's URL, so a script started with --port 0 can read where to connect instead of parsing text (next release):

    {"time":"…","level":"info","msg":"Listening on port 51234","event":"listening","data":{"port":51234,"servers":[{"name":"default","path":"/","outputTransport":"sse","url":"http://localhost:51234/sse"}]}}
    

    For example: supergateway --stdio "…" --port 0 --logFormat json | jq -r --unbuffered 'select(.event == "listening") | .data.servers[0].url'

  • --cors: Enable CORS (stdio→SSE or stdio→WS mode). Use --cors with no values to allow all origins, or supply one or more allowed origins (e.g. --cors "http://example.com" or --cors "/example\\.com$/" for regex matching). With origins, a web page from any other origin can't open a WebSocket either (403); clients that aren't browsers send no origin and are unaffected. Without --cors or a key, a page on another site can't open a WebSocket to this machine's loopback address (see Security).

  • --healthEndpoint /healthz: Register one or more endpoints (every mode but stdio output; can be used multiple times) that respond with "ok"

  • --healthCheck gateway | server: What the health endpoints check (default: gateway). gateway answers "ok" while the gateway is up. server also checks the MCP server: it starts one (or, for --sse/--streamableHttp, opens a session with the remote server), initializes and pings it, and stops it. It answers "ok" if the server responded within 10 seconds, and 503 with the reason otherwise (e.g. unhealthy: the server exited (code=1, signal=null)). The answer is reused for 10 seconds, so polling every second starts at most one server per 10 seconds. The startup log says when health turns bad and when it recovers

  • --toolPrefix "github_": Put this before every tool name the server lists, so search becomes github_search (all modes). Clients call the tool by that name, and the server still gets its own. It is used as given, so include a separator. Tool names may be letters, digits, _, - and ., at most 128 characters; the gateway warns about a prefix or name outside that

  • --tools search --tools get_issue: Expose only these tools, by the server's own names (all modes). The others are left out of tools/list, and a call to one is refused with -32602 Unknown tool, as a server refuses a tool it doesn't have, without reaching the server. A bare --tools exposes none

  • --toolName search=github_search: Give one tool another name: its own name, =, and the name clients see (all modes; repeat for several tools). Clients see and call it by exactly that name (--toolPrefix goes on the other tools only), and a call by the old name is refused as for a tool the server doesn't have. --tools keeps using the server's own names. Two tools may swap names; two can't get the same one. In a config file it is toolNames

  • --apiKey "some-key": Require clients to present this key, as Authorization: Bearer <key> or X-API-Key: <key> (stdio→SSE, stdio→WS or stdio→Streamable HTTP mode; can be used multiple times). Also SUPERGATEWAY_API_KEY=some-key. See Requiring an API key

  • --apiKeyFile /run/secrets/keys: Accept the keys in this file, one per line (blank lines are skipped). Also SUPERGATEWAY_API_KEY_FILE=/run/secrets/keys

  • --exitWithProcess <pid>: Shut down, stopping the MCP server, when process <pid> exits (all modes). Pass the launcher's PID (e.g. $$); it need not be the direct parent, so it works through npx. Checked about once a second. A launcher that spawns Supergateway with a stdin pipe doesn't need this: since 4.0 Supergateway exits when its stdin closes.

  • --config servers.json: Read servers and settings from a config file instead of the server flags. See Several servers from a config file

  • --checkConfig: With --config, check the file, list each server's path and output, and exit

  • --printConfig: Print the resolved config and exit. Keys, bearer tokens, every env value, the query of every URL and headers with sensitive names are replaced; command lines (args, stdio) are printed as written, so read it over before sharing it. Without --config it prints the file equivalent to the command line given

What's new since 3.x

Still on 3.4.3? A typical 3.x command line works unchanged. Coming from 3.x lists what you could notice when you upgrade, and which workarounds you can drop. "(next release)" marks what is on main but not yet published.

  • Several servers on one port from a config file in the mcpServers format clients use (4.2.0), or combined into one MCP server (4.2.0).
  • --apiKey to require a key from clients (4.2.0), and --host to choose the address to listen on (4.2.0). See Security.
  • Health endpoints that check the server: --healthCheck server answers 503 with the reason when the server can't start or answer (4.2.0). See Docker and Kubernetes.
  • Tool names: --toolPrefix and --tools (4.2.0), and --toolName or toolNames to rename single tools (4.4.0).
  • A server process per client: each SSE and WebSocket connection gets its own (4.1.0). Sharing and pooling processes, with which servers can be shared (next release).
  • --logFormat json: one JSON object per log line (4.2.0).
  • Remote servers over any transport: --sse and --streamableHttp served over SSE, WebSocket or Streamable HTTP (details, 4.2.0).
  • A library API: startSupergateway, with status and hooks (next release).
  • Standalone executables with Node built in, and a Homebrew formula (4.2.0).
  • Debian (glibc) images: debian, uvx-debian and deno-debian (next release).
  • Signed images with an SBOM (next release).
  • A Helm chart set up by a config file (next release).
  • Recipes for a gateway per user, a reverse proxy, Docker and Kubernetes, Docker Compose, systemd, a Windows service, Render's free plan, and starting it from code.

stdio → SSE

Expose an MCP stdio server as an SSE server:

npx -y supergateway \
    --stdio "npx -y @modelcontextprotocol/server-filesystem ./my-folder" \
    --port 8000 --baseUrl http://localhost:8000 \
    --ssePath /sse --messagePath /message
  • Subscribe to events: GET http://localhost:8000/sse
  • Send messages: POST http://localhost:8000/message
  • Each SSE connection gets its own server process.

SSE → stdio

Connect to a remote SSE server and expose locally via stdio:

npx -y supergateway --sse "https://mcp-server-ab71a6b2-cd55-49d0-adba-562bc85956e3.supermachine.app"

Useful for integrating remote SSE MCP servers into local command-line environments.

You can also pass headers when sending requests. This is useful for authentication:

npx -y supergateway \
    --sse "https://mcp-server-ab71a6b2-cd55-49d0-adba-562bc85956e3.supermachine.app" \
    --oauth2Bearer "some-access-token" \
    --header "X-My-Header: another-header-value"

Streamable HTTP → stdio

Connect to a remote Streamable HTTP server and expose locally via stdio:

npx -y supergateway --streamableHttp "https://mcp-server.example.com/mcp"

This mode is useful for connecting to MCP servers that use the newer Streamable HTTP transport protocol. Like SSE mode, you can also pass headers for authentication:

npx -y supergateway \
    --streamableHttp "https://mcp-server.example.com/mcp" \
    --oauth2Bearer "some-access-token" \
    --header "X-My-Header: another-header-value"

stdio → Streamable HTTP

Expose an MCP stdio server as a Streamable HTTP server.

Supports legacy MCP and 2026-07-28 when the client and stdio server support a common protocol version. Clients that support automatic negotiation can fall back to legacy when the server requires it.

--stateful preserves legacy sessions. MCP 2026-07-28 uses independent requests and does not create a transport session.

Interactive MCP 2026-07-28 operations can continue across requests. Continuations and explicit retries are available for up to five minutes of inactivity, with at most 64 saved continuation states. Older states may expire sooner when this limit is reached.

Stateless mode

npx -y supergateway \
    --stdio "npx -y @modelcontextprotocol/server-filesystem ./my-folder" \
    --outputTransport streamableHttp \
    --port 8000

Stateful mode

npx -y supergateway \
    --stdio "npx -y @modelcontextprotocol/server-filesystem ./my-folder" \
    --outputTransport streamableHttp --stateful \
    --sessionTimeout 60000 --port 8000

The Streamable HTTP endpoint defaults to http://localhost:8000/mcp (configurable via --streamableHttpPath).

stdio → WS

Expose an MCP stdio server as a WebSocket server:

npx -y supergateway \
    --stdio "npx -y @modelcontextprotocol/server-filesystem ./my-folder" \
    --port 8000 --host 127.0.0.1 --outputTransport ws --messagePath /message \
    --cors "http://localhost:3000"
  • WebSocket endpoint: ws://localhost:8000/message
  • Each WebSocket connection gets its own server process.
  • Browsers apply no CORS to WebSockets, so without --cors or --apiKey any web page can use the server, even on 127.0.0.1. With --cors and origins, only pages from those origins can (above: a web app on localhost:3000). Without either, the gateway prints a startup warning and logs each web page origin that connects.

Remote server → SSE, WS or Streamable HTTP

Serve a remote MCP server to clients that need another transport, or behind your own API key:

npx -y supergateway \
    --streamableHttp "https://mcp.example.com/mcp" \
    --oauth2Bearer "$UPSTREAM_TOKEN" \
    --outputTransport streamableHttp --stateful --apiKey "$MCP_API_KEY"
  • Each client session gets its own session with the remote server, ended when the client's ends, and at shutdown.
  • --header and --oauth2Bearer go to the remote server. The client's own Authorization and API key never do.
  • A redirect from the remote server is followed. The headers go with it on the same origin, or from http to https on the same host; a redirect to any other origin is followed without them, and logged once.
  • Requests from the remote server to the client (sampling, roots, elicitation) are passed through.
  • A remote server that is down, refuses the client or goes away fails that session only.
  • The 2026-07-28 protocol's stateless requests are passed on to a remote Streamable HTTP server that speaks that version. The gateway asks it once a minute (server/discover). One that doesn't, and any remote SSE server, is served as before: its clients are told the version isn't supported, and those that negotiate fall back to an earlier one.

Requiring an API key

By default anyone who can reach the port can use the server. With --apiKey, every request to stdio→SSE, stdio→WS or stdio→Streamable HTTP must carry a key:

npx -y supergateway \
    --stdio "npx -y @modelcontextprotocol/server-filesystem ./my-folder" \
    --outputTransport streamableHttp --apiKey "$MCP_API_KEY"

curl -H "Authorization: Bearer $MCP_API_KEY" ...   # or: -H "X-API-Key: $MCP_API_KEY"
  • A request without a valid key gets 401 Unauthorized. The --healthEndpoint paths and, with --cors, browser preflight requests stay open.
  • Keys from --apiKey, --apiKeyFile, SUPERGATEWAY_API_KEY and SUPERGATEWAY_API_KEY_FILE are all accepted together, so a key can be rotated by adding the new one before removing the old.
  • An empty key, an unreadable key file or one with no keys stops the gateway at startup rather than running it without authentication.
  • Without a key, a gateway that other machines can reach (no --host, 0.0.0.0, :: or a network address) prints a WARNING: No API key is set line on stderr after its startup listing, even with --logLevel none. It changes nothing else. With several servers in a --config file, it names the ones without a key. --host 127.0.0.1, localhost or ::1 keeps it local and quiet.
  • Keys are never logged. Use HTTPS (e.g. behind a reverse proxy) so they are not sent in clear text.
  • To send a key to a remote server from SSE→stdio or Streamable HTTP→stdio, use --header or --oauth2Bearer; --apiKey is refused there.

Security

The defaults keep every existing setup working, so they are open: a gateway listens on every interface and serves anyone who reaches it. Lock it down to what you need:

  • Only this machine? Add --host 127.0.0.1.
  • Anything else can reach it (other machines, containers, a reverse proxy)? Add --apiKey. A key is also the one thing a web page can't supply, so it stops browsers too.
  • A web app uses it over WebSocket? List the app's origins with --cors; pages from other origins are refused.

Two startup warnings on stderr say when one of these is missing, even with --logLevel none: WARNING: No API key is set (see Requiring an API key), and, for stdio→WS without --cors or a key, WARNING: Neither --cors nor an API key is set. Neither changes what the gateway does. To report a vulnerability, see SECURITY.md.

Without a key, the gateway also refuses two things a web page in its visitor's browser could try against a gateway on that visitor's own machine. Both apply only to a browser's requests that reach this machine on a loopback address (127.0.0.1, ::1); clients that aren't browsers send no Origin, and other machines' connections aren't loopback, so neither is ever affected:

  • DNS rebinding. A page at a name of its own that now points at this machine, asking same-origin, gets 403 (Forbidden: host not allowed), logged once per name. Names of this machine (localhost, *.localhost, any address) are never refused. If you serve a web page on a public name through a tunnel or proxy on this machine and it uses the gateway on that same name, allow it with --cors and its origin (or --baseUrl with that name, for SSE).
  • A page on another site over WebSocket, without --cors. Gets 403 (Forbidden: origin not allowed), logged with the --cors that would allow it. Pages on this machine or a network it is on (localhost, *.localhost, a private, 100.64.0.0/10, link-local or unique local address, or one of this machine's own addresses) and browser extensions still connect. A page served from any other address is another site.

Several servers from a config file

--config reads the mcpServers file that Claude Desktop and other MCP clients use, so a client's file works as-is. Each server is served at /<name> on one port:

{
  "port": 8000,
  "mcpServers": {
    "git": { "command": "uvx", "args": ["mcp-server-git"] },
    "files": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "./my-folder"],
      "outputTransport": "streamableHttp",
      "apiKey": "${FILES_KEY}",
    },
  },
}
npx -y supergateway --config servers.json
  • git is served over SSE at http://localhost:8000/git/sse and /git/message; files over Streamable HTTP at http://localhost:8000/files/mcp.
  • A server is command + args (run without a shell, as clients run them), stdio (a shell command line, as --stdio), or url + type (sse or http). env and cwd set its environment and directory.
  • Any option from the list above can be set on a server, by its flag name (outputTransport, stateful, cors, headers, apiKey, healthEndpoint, toolPrefix, tools, ...). Set at the top level, it is the default for every server. Defaults are the command line's: a local server is served over SSE, a url one on stdio. A top-level headers or oauth2Bearer in a file that also has a remote server is that server's: a local or combined server that only inherits it doesn't put its credentials (the bearer token and headers named like Authorization, *-Token or *-Key) on its responses. Set them on the server itself to do that.
  • toolNames gives some of a server's tools other names, by the server's own name: "toolNames": { "doctor": "environment_check" }. On the command line, it is --toolName doctor=environment_check, once per tool.
    • Clients see and call each renamed tool by exactly its new name: toolPrefix goes on the other tools only. A call by the old name is refused, as for a tool the server doesn't have.
    • A new name is 1 to 128 letters, digits, _, - and ., and two tools can't get the same one. Two tools may swap names.
    • tools keeps using the server's own names. A tool whose name is another's new name is left out, with a line in the log, and that name calls the renamed one.
    • A rename of a tool the server doesn't have is logged once.
  • path serves a server somewhere other than /<name>. A name that can't be part of a URL needs one. The gateway refuses to start if a server's URL would be answered by another server or by the gateway's own healthEndpoint.
  • port, host, logLevel, logFormat, exitWithProcess and the top-level healthEndpoint are the gateway's own. A top-level healthEndpoint answers for the whole gateway; one on a server is under that server's path. With "healthCheck": "server", a server's own health endpoints check that server; with two or more servers, the gateway's stay "ok" while the gateway is up, so one failing server doesn't fail the whole gateway. A file with one server runs as that server alone, as its command line would, so there the top-level endpoints check it too.
  • apiKey on a server locks that server only, and replaces a top-level apiKey. An empty list is refused; to leave one server without a key, set apiKey on the servers that need one instead of at the top level. Keys from --apiKey, --apiKeyFile or SUPERGATEWAY_API_KEY lock every server.
  • "disabled": true skips a server. Keys only clients use (autoApprove, timeout, disabledTools, ...) are warned about and ignored. Any other unknown key is an error that suggests the closest known one.
  • ${VAR}, ${VAR:-default} and ${env:VAR} are replaced from the environment in every value except a stdio command line, which the shell expands itself. A variable that isn't set is an error. $$ is a literal $.
  • Flags beside --config may be the gateway's own (--port, --host, --logLevel, --logFormat, --exitWithProcess, --healthEndpoint, --apiKey, --apiKeyFile). They override the file, and the startup log says so. A server flag such as --stateful is refused, because it would be unclear which server it means.
  • With more than one server, each log line about a server starts with its name ([git]), and JSON logs give it a server field.
  • On Windows, "command": "npx" works as it does in other clients: a command that is a script, such as npx.cmd, runs through cmd.exe, and each argument still reaches the server as written. stdio runs through the shell.
  • Comments and trailing commas are allowed (JSONC). Run --checkConfig after editing.

A url server is served like a local one when it has an output other than stdio (see Remote server → SSE, WS or Streamable HTTP): "outputTransport": "streamableHttp", for example.

One url server may use stdio output beside servers on the port. This is for a client that launches Supergateway with a config file, such as Claude Desktop: it talks to that server over stdin and stdout, and other clients reach the rest over HTTP. All logs then go to stderr. The process belongs to the client that started it. When stdin closes, a signal arrives, or the stdio server stops (its remote server refused the first connection, for example), every server stops, and the exit code is the stdio server's.

Combining servers on one URL

An entry with its own mcpServers serves them as one MCP server, at the entry's URL:

{
  "port": 8000,
  "outputTransport": "streamableHttp",
  "mcpServers": {
    "dev": {
      "mcpServers": {
        "git": { "command": "uvx", "args": ["mcp-server-git"] },
        "files": {
          "command": "npx",
          "args": ["-y", "@modelcontextprotocol/server-filesystem", "."],
        },
        "docs": {
          "url": "https://docs.example.com/mcp",
          "type": "http",
          "toolPrefix": "docs_",
        },
      },
    },
  },
}

A client of http://localhost:8000/dev/mcp sees the tools, prompts and resources of all three.

  • Names are kept unless you rename them. A request goes to the server that has the tool, prompt or resource it names. When two servers offer the same name, the first one listed wins and the other's is hidden; the log says so once. Set toolNames on a server to rename the tools that clash, or toolPrefix to rename all of its tools, and tools to choose which of a server's tools are shown. Prompts and resources are not renamed. Many tools behind one URL make a model's choice harder, so combine what belongs together.
  • Each session has its own servers, started when the client initializes. A server that can't start is left out, with a line in the log; the session fails only if none starts. A server that stops later fails the calls it had, the client is told the lists changed, and the rest go on.
  • Requests from a server to the client (sampling, roots, elicitation) work as they do for one server, on outputs that carry them (SSE, WebSocket, stateful Streamable HTTP).
  • The protocol version is the lowest any of the servers answers; the capabilities are everything any of them has; their instructions are joined, each under its server's name.
  • Lists come as one page, every server's in the order listed.
  • Settings for the URL (outputTransport, apiKey, cors, healthEndpoint, ...) go on the entry. A combined server has command/args/env/cwd, stdio, or url/type/headers/oauth2Bearer, and toolPrefix/tools/toolNames. Combining goes one level deep.
  • On stdio ("outputTransport": "stdio"), a combined entry is what a desktop client launches to reach several servers through one entry of its own config. It can run beside servers on the port, as a single remote server can.
  • 2026-07-28 is answered when every combined server speaks it (the gateway asks them once a minute). Each request then starts only the server it is for; server/discover and the lists go to every server. If one server doesn't speak it, the entry answers the earlier versions, and clients that negotiate fall back.
  • Not yet: tasks. Combined servers share one model context, so combine only servers you trust with each other's results.

Server processes

By default every client gets a server process of its own: one per SSE or WebSocket connection, one per stateful Streamable HTTP session, and one per request in stateless mode and for 2026-07-28 requests. When the client is done, its process stops. That keeps clients apart, but each process costs memory, and a server that is slow to start is slow for every request.

These settings change that. They go in a config file: on a server, on a combined server, or at the top level as a default. There are no flags for them yet.

{
  "mcpServers": {
    "fetch": {
      "command": "uvx",
      "args": ["mcp-server-fetch"],
      "outputTransport": "streamableHttp",
      "processSharing": "sequential", // reuse warm processes, one client at a time
      "maxProcesses": 4, // at most 4; further requests wait
      "processIdleTimeout": 300000, // an idle one is stopped after 5 minutes
    },
    "backlog": {
      "command": "backlog",
      "args": ["mcp", "start"],
      "outputTransport": "streamableHttp",
      "stateful": true,
      "processSharing": "all", // one process for every client
    },
  },
}
  • "processSharing": who may use a server process.
    • "none" (the default): every client gets its own, as described above.
    • "sequential": a process serves one client at a time and is then kept for the next. A client gets a kept process only if that process was started with the same handshake (protocol version and client details), and only if it was left owing nothing: every request answered both ways. A kept process answers the next client's initialize with what it answered the first time. This removes the start-up cost of each request.
    • "all": every client of the server shares its processes at once. The process sees one client, the gateway: it is initialized once, with no client capabilities, and each client's initialize is answered from that.
      • Each client still sees a server of its own: its request ids, progress, cancellations, subscriptions, log level and tasks stay its own.
      • What the server asks a client during a call (sampling, elicitation, roots) goes to the one client with a call in flight; with none or several, the server is told no client can answer.
      • A process that stops fails the requests it had, and is started again (see processRestart); its clients stay connected.
      • Legacy clients and 2026-07-28 requests use separate shared processes.
  • "maxProcesses": the most processes the server runs at once. For "all", how many shared processes (1 by default), with clients spread across them; legacy and 2026-07-28 clients each have up to this many.
    • A stateless or 2026-07-28 request past it waits for a process (see queueTimeout), then gets 503 with Retry-After.
    • A new session past it (SSE, stateful HTTP) gets 503 with Retry-After at once; a WebSocket is closed with code 1013 (try again later).
  • "minProcesses": processes started up front and kept running ("sequential" or "all"). It also shows at startup whether the server starts at all.
  • "processIdleTimeout": ms an idle kept process waits before it is stopped ("sequential"). Never below minProcesses.
  • "maxQueuedRequests": how many requests may wait for a process (Streamable HTTP, with maxProcesses). Past it, 503 at once.
  • "queueTimeout": ms a request waits for a process. 30000 by default.
  • "processMaxRequests": replace a process after it has served this many clients ("sequential" or "all"). It finishes with the clients it has.
  • "processMaxAge": replace a process after this many ms ("sequential" or "all"), the same way.
  • "processMaxMemory": MB a server's processes (the whole process tree, wrapper included) may use. Past it, the process is stopped at once: what it was doing fails. In "all" it is then started again.
  • "processRestart": "onFailure" (the default) or "never". Whether a process kept running ("all", or "sequential" with minProcesses) is started again when it stops by itself. The wait doubles from 1 s up to 30 s. After 5 restarts within a minute it gives up: the health check ("healthCheck": "server") fails, and with "all" new clients get 503. A process started for a serverProcess key or env counts its restarts on its own: when it gives up, only the clients of that key or env get 503, for a minute. Neither it nor a process started with the server's own env affects the other's clients.
  • "processStartTimeout": ms from a process's first request until it says anything. Past it, the request fails and the process is stopped.
  • "processStopTimeout": ms a stopped process has between SIGTERM and SIGKILL. 5000 by default. On Windows a server's process tree is ended at once.
  • "maxSessions": the most live sessions (SSE, WebSocket, stateful Streamable HTTP) a server's URL takes. Past it, 503 with Retry-After, or WebSocket close code 1013.
  • "requestTimeout": ms a client's request may take. Past it, the request is cancelled at the server and answered with error -32001. Any server, local or remote; initialize is left to processStartTimeout.

A setting that can't do anything where it is set is an error: processIdleTimeout without "sequential", maxSessions on stateless HTTP, any process setting on a remote server. A top-level setting is a default, so it applies to the servers it can.

With "healthCheck": "server", a server whose processes are pooled is checked through a process its clients use (the shared one with "all"); with every process busy, it counts as answering, and the check never makes a client wait.

Which servers can be shared

"sequential" and "all" let a server's processes serve more than one client, so whatever a process keeps between requests is shared too: an open browser page, a logged-in account, files it wrote, the "current" project or cluster. Every client also acts with the process's one set of credentials. Before you set either, check the server:

Kind of server Examples Sharing
Stateless lookups fetch, time, context7, aws-documentation, duckduckgo Safe
API wrappers with one token GitHub or GitLab (with a personal access token), Notion, Atlassian, Slack (bot token), Supabase, Firecrawl, Brave, Exa, Tavily, Postgres Safe if every client may act as that one identity, and share its quota
Browser automation Playwright, Chrome DevTools, Puppeteer Not safe: clients share tabs, cookies and logins, and drive the same page
Memory, notes and history server-memory, sequential-thinking Not safe unless every client should see the same memory
Shells, projects and contexts Desktop Commander, Serena, Kubernetes, MongoDB connect Not safe: one client changes what the others act on
Servers that log in by OAuth GitHub or GitLab in OAuth mode Not safe: the first client to log in is who everyone acts as
Servers that ask the client filesystem with roots from the client, servers that need elicitation or sampling Not with "all": the process asks no client for roots, and a question with several clients in flight can't be routed

"sequential" shares less than "all": one client at a time, never two at once. It still carries state from one client to the next, so the same table applies.

From code

Start a gateway inside your own Node program instead of spawning the command. startSupergateway takes the command line's flags, by the same names and with the values they take, and resolves once it listens:

import { startSupergateway } from 'supergateway'

// supergateway --stdio "uvx mcp-server-git" --outputTransport streamableHttp --port 0 --host 127.0.0.1
const gateway = await startSupergateway({
  stdio: 'uvx mcp-server-git',
  outputTransport: 'streamableHttp',
  port: 0, // the system picks a free port
  host: '127.0.0.1',
})

gateway.port // the port it listens on
gateway.servers // [{ name: 'default', path: '/', outputTransport: 'streamableHttp', url: 'http://127.0.0.1:53124/mcp' }]

await gateway.close() // stops listening, every session and every server process
  • Flags as on the command line. A flag you can repeat (header, apiKey, cors, tools, toolName, healthEndpoint) takes a string or an array of strings. A flag given without a value takes true: stateful: true, and cors: true for any origin. Unset flags have their usual defaults, so port is 8000 unless you give one.

  • config takes a file's path, or the config itself as the config file holds it. Beside it go the flags the command line allows there, such as port:

    await startSupergateway({
      port: 0,
      config: {
        mcpServers: { git: { command: 'uvx', args: ['mcp-server-git'] } },
      },
    })
  • It refuses what the command line refuses, with the same messages, and also a flag it doesn't know or a value of the wrong type. A port in use rejects with EADDRINUSE. Nothing is left running after a rejection.

  • It leaves your process alone. It installs no signal handlers, never exits, and logs nothing unless you give a logger. exitWithProcess closes the gateway instead of exiting. printConfig and checkConfig belong to the command line: configOf(flags) returns the config the flags stand for, secrets included, and rejects as the gateway would.

  • A remote server on stdio ({ streamableHttp: url } or { sse: url }) is served on your process's stdin and stdout, as the command does. The end of stdin closes the gateway, and gateway.closed resolves however it stops.

  • Options, both optional, as a second argument:

    • logger: { info, error }, which receives the lines the command line would log, warnings included, as logLevel and logFormat have them.
    • env: where ${VAR} in a config and SUPERGATEWAY_API_KEY / SUPERGATEWAY_API_KEY_FILE are read from. Defaults to process.env.
  • Types: SupergatewayFlags, SupergatewayConfig, SupergatewayOptions and Supergateway are exported.

Status

gateway.status() says what the gateway is doing now, as plain JSON. It starts and probes nothing, and holds no env, arguments, headers or keys:

gateway.status()
// {
//   state: 'running', // then 'closing', 'closed'
//   port: 53124, host: '127.0.0.1',
//   servers: [{
//     name: 'default', path: '/', outputTransport: 'streamableHttp', url: 'http://127.0.0.1:53124/mcp',
//     connections: 2, // open SSE and WebSocket connections, stateful sessions
//     health: { state: 'healthy', checkedAt: '2026-12-05T10:00:00.000Z' }, // or 'unknown', 'unhealthy' with error
//     processes: { running: 2, idle: 1, queued: 0, restarts: 0, lastExit: { code: 0, signal: null, at: '…' } },
//   }],
// }

health is the last health check's result (healthCheck: 'server'), or unhealthy once a server's processes keep stopping; unknown until something has told. idle, queued and restarts count the processes kept or shared.

Hooks

Functions given with the options, called as the gateway serves. None is a command-line flag. Each is told which server it is about.

await startSupergateway(flags, {
  // Every HTTP request and WebSocket upgrade, before it is served.
  onRequest: ({ server, method, path, headers, remoteAddress }) => {
    if (!isAllowed(headers))
      return { refuse: { status: 401, message: 'Sign in first' } }
  },
  // Every JSON-RPC message, both ways. A request to the server can be refused:
  // the client gets an error under its id.
  onMessage: async ({ server, direction, message }) => {
    if (
      direction === 'toServer' &&
      message.method === 'tools/call' &&
      !(await hasCredit())
    )
      return { refuse: { code: -32000, message: 'Out of credit' } }
  },
  // A process for this request's client: env added to its environment, and the
  // key of the processes it may share or reuse.
  serverProcess: ({ headers }) => ({
    env: { GITHUB_TOKEN: tokenFor(headers.authorization) },
  }),
  onProcessExit: ({ server, pid, code, signal }) => {},
  onHealthChange: ({ server, healthy, error }) => {},
})
  • Refusing: onRequest and onMessage return { refuse: { message, status?, code? } } to refuse. A refused request gets that HTTP status (403 by default) and a JSON-RPC error body; a refused message to the server is answered with that JSON-RPC error code (-32000 by default) if it is a request, and dropped if it is a notification. A client's answer to the server is never refused. A refusal is message: a string, status: 400 to 599, code: an integer; anything else refuses with the fixed message below, and is logged.
  • Order: messages to the server wait for onMessage, one after another, so none overtakes another. Messages to the client are only shown to it and are never held. A hook gets a copy of each message and of the request's headers: what it does with them changes nothing.
  • Errors: a refusing hook that throws refuses with a fixed message (500 for a request, -32603 for a message), never its own error's, which goes to your logger. What onProcessExit and onHealthChange throw is logged.
  • Processes per user: clients whose serverProcess returns different keys never share or reuse a process. Without a key, the env is the key, so different credentials never meet in one process.
    • Each process starts with the env of the client it was started for. Kept or shared processes (Server processes) serve only clients of their key. Those started up front (minProcesses) serve only clients with no key.
    • maxProcesses counts every key's processes together. A new key's process takes the place of an idle one of another key, or, with every one busy, the client gets 503 with Retry-After. A key's process with no client left stops after processIdleTimeout, or a minute.
    • A session (SSE, stateful Streamable HTTP) and a 2026-07-28 continuation belong to the key that opened them: a client of another key is told they don't exist. Without a key the env is the key, so if the env varies per request (a short-lived token), give a key that doesn't, or a session opened under one env is refused under the next.
    • A client that leaves while its server is still starting doesn't hand it on to the next client, as it does without the hooks.
    • serverProcess is synchronous and asked for every request; fetch what it needs in onRequest. It returns { env?: { [name]: string }, key?: string }; anything else refuses the request. A remote server has no process to give the env to.
  • Health endpoints are never shown to onRequest or serverProcess: probes aren't clients, and an auth hook mustn't fail them.
  • A server on stdio output (a remote one bridged, or servers combined) gets onMessage too; it has no HTTP requests, so onRequest and serverProcess don't apply. A health check's process is started without serverProcess: it serves no client.

streamableHttpToStdio and sseToStdio are still exported for programs that already use them. They take the process over and exit when the client goes away.

What supergateway exports follows semver, as the command line does. Files under supergateway/dist/ keep importing as they do today, and the ones dependents use are tested to stay where they are, but the rest of dist/ is the gateway's own and can change.

Without Node: standalone executables

Each release also ships Supergateway as a single executable with Node built in, so it runs where Node is not installed. It takes the same flags.

Homebrew (macOS and Linux):

brew install supercorp-ai/tap/supergateway

mise (macOS, Linux and Windows):

mise use -g github:supercorp-ai/supergateway

It picks the archive for the platform (the linux-musl one on Alpine), and checks its build attestation. Pin a version with @4.4.0; executables exist from 4.2.0. On an Intel Mac, mise use -g npm:supergateway installs the npm package instead, on mise's or your Node.

macOS (Apple Silicon) and Linux: download and unpack. Use linux-x64, linux-arm64, linux-musl-x64 or linux-musl-arm64 in place of darwin-arm64 as needed.

curl -fsSL https://github.com/supercorp-ai/supergateway/releases/latest/download/supergateway-darwin-arm64.tar.gz | tar -xz
./supergateway --stdio "uvx mcp-server-time" --port 8000

Windows (PowerShell):

Invoke-WebRequest https://github.com/supercorp-ai/supergateway/releases/latest/download/supergateway-win-x64.zip -OutFile supergateway.zip; Expand-Archive supergateway.zip .
.\supergateway.exe --stdio "uvx mcp-server-time" --port 8000

Good to know:

  • The MCP server you wrap still needs its own runtime: --stdio "npx -y ..." needs Node, --stdio "uvx ..." needs uv.
  • Linux needs glibc 2.28 or later. On Alpine use the linux-musl build and run apk add libstdc++ first.
  • Intel Macs have no standalone build; brew install gives them the npm package on Homebrew's Node instead.
  • The executables are not code-signed by a paid certificate. Downloaded from a browser, macOS Gatekeeper and Windows SmartScreen ask before the first run; curl, PowerShell and Homebrew installs are not affected.
  • Every archive is listed in the release's SHA256SUMS, and you can check it was built by this repository's CI with gh attestation verify supergateway-darwin-arm64.tar.gz -R supercorp-ai/supergateway.

Shutdown

Allow more than five seconds for graceful shutdown. Child servers should handle SIGTERM when you stop the gateway with Ctrl-C.

For network-output gateways, closing a pipe connected to stdin also stops the gateway. Starting with stdin ignored or redirected from /dev/null keeps it running.

Example with MCP Inspector (stdio → SSE mode)

  1. Run Supergateway:
npx -y supergateway --port 8000 \
    --stdio "npx -y @modelcontextprotocol/server-filesystem /Users/MyName/Desktop"
  1. Use MCP Inspector:
npx @modelcontextprotocol/inspector

You can now list tools, resources, or perform MCP actions via Supergateway.

Using with ngrok

Use ngrok to share your local MCP server publicly:

npx -y supergateway --port 8000 --stdio "npx -y @modelcontextprotocol/server-filesystem ."

# In another terminal:
ngrok http 8000

ngrok provides a public URL for remote access.

MCP server will be available at URL similar to: https://1234-567-890-12-456.ngrok-free.app/sse

Running with Docker

A Docker-based workflow avoids local Node.js setup. A ready-to-run Docker image is available here: supercorp/supergateway. Also on GHCR: ghcr.io/supercorp-ai/supergateway

Using the Official Image

docker run -it --rm -p 8000:8000 supercorp/supergateway \
    --stdio "npx -y @modelcontextprotocol/server-filesystem /" \
    --port 8000

Docker pulls the image automatically. The MCP server runs in the container’s root directory (/). You can mount host directories if needed.

Images with dependencies

Pull any of these pre-built Supergateway images for various dependencies you might need.

  • uvx Supergateway + uv/uvx, so you can call uvx directly:

    docker run -it --rm -p 8000:8000 supercorp/supergateway:uvx \
      --stdio "uvx mcp-server-fetch"
  • deno Supergateway + Deno, ready to run Deno-based MCP servers:

    docker run -it --rm -p 8000:8000 supercorp/supergateway:deno \
      --stdio "deno run -A jsr:@omedia/mcp-server-drupal --drupal-url https://your-drupal-server.com"

Debian (glibc) images

The images above are built on Alpine Linux, which uses musl. Some servers need glibc instead. Examples are Python packages that publish only manylinux wheels, and npm packages whose prebuilt native binaries are glibc-only. For those, each image has a Debian counterpart, built on node:24-trixie-slim:

Alpine (default) Debian (glibc)
latest debian
uvx uvx-debian
deno deno-debian
docker run -it --rm -p 8000:8000 supercorp/supergateway:uvx-debian \
  --stdio "uvx mcp-server-fetch"

Each version is also tagged on its own, as <version>-debian, <version>-uvx-debian and <version>-deno-debian, and release candidates get next-debian, next-uvx-debian and next-deno-debian. To add system packages to a Debian image, use apt-get rather than apk.

Building the Image Yourself

Build from this checkout:

npm ci
npm run pack:release
docker build -f docker/base.Dockerfile -t supergateway \
  --build-arg VERSION="$(node -p "require('./.release/manifest.json').version")" \
  --build-arg PACKAGE_SHA256="$(node -p "require('./.release/manifest.json').sha256")" .

docker run -it --rm -p 8000:8000 supergateway --stdio "npx -y @modelcontextprotocol/server-filesystem ."

Kubernetes (Helm)

(next release) A Helm chart runs the same images. Its values hold a config file, under config:

# values.yaml
config:
  outputTransport: streamableHttp
  healthEndpoint: /healthz
  healthCheck: server
  mcpServers:
    fetch:
      command: uvx
      args: [mcp-server-fetch]
image:
  variant: uvx
apiKey:
  existingSecret: mcp-keys # a Secret with the keys under `api-keys`, one per line
helm install mcp oci://ghcr.io/supercorp-ai/charts/supergateway -f values.yaml

Clients in the cluster use http://mcp-supergateway/fetch/mcp with a key.

  • The chart's version is the Supergateway version it runs. Release candidates are pre-release chart versions: Helm installs them only with --version or --devel.
  • The config's top-level healthEndpoint is the readiness probe. The other values are only about Kubernetes: the image variant, API keys from a Secret, the Service, an Ingress, resources and scheduling. The pod runs as the images' non-root node user.
  • The chart is signed like the images. See its README for every value and how to verify it.

Verifying what you downloaded

Everything we publish can be traced to the exact commit and GitHub workflow that built it. You don't have to check, and nothing changes if you don't. These steps are for anyone who wants to, or whose company requires it.

npm package. It is published from CI with npm provenance:

npm audit signatures

Standalone executables. Each archive is listed in the release's SHA256SUMS and has a build attestation. For releases after 4.4.0, each archive also has an attested SBOM, the list of npm packages the executables bundle:

gh attestation verify supergateway-linux-x64.tar.gz -R supercorp-ai/supergateway

# The SBOM attested to it
gh attestation verify supergateway-linux-x64.tar.gz -R supercorp-ai/supergateway \
  --predicate-type https://spdx.dev/Document/v2.3 --format json \
  --jq '.[0].verificationResult.statement.predicate'

Docker images. These steps apply to images released after 4.4.0. Older images carry build provenance but no signature or SBOM.

  • Each image is signed with cosign, keyless, by the publishing workflow.
  • Each signature is stored beside its image, as a sha256-<digest>.sig tag in the same repository. If a script picks the newest tag by sorting every tag, filter those out.
  • Each image carries full build provenance and, from then on, an SBOM of every package inside.
# The signature: made by this repository's publishing workflow
cosign verify supercorp/supergateway:uvx \
  --certificate-identity-regexp '^https://github.com/supercorp-ai/supergateway/\.github/workflows/docker-publish\.yaml@refs/' \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com

# The build attestation: which commit and workflow run built it
gh attestation verify oci://supercorp/supergateway:uvx -R supercorp-ai/supergateway

# The SBOM: every package inside, for vulnerability scanners
docker buildx imagetools inspect supercorp/supergateway:uvx --format '{{ json .SBOM }}'

The same commands work for ghcr.io/supercorp-ai/supergateway. It is the same image, with the same digest. In Kubernetes, a Sigstore policy (Kyverno or policy-controller) with the identity above admits only images we signed.

Recipes

Complete setups for what people build most often. Each links to the sections with the details.

A gateway per user

When each user must reach the server with their own credentials, such as their own API token. Give each user an entry of their own in a config file, with their own key and token:

{
  "port": 8000,
  "outputTransport": "streamableHttp",
  "mcpServers": {
    "alice": {
      "command": "npx",
      "args": ["-y", "@notionhq/notion-mcp-server"],
      "env": { "NOTION_TOKEN": "ntn_alices_token" },
      "apiKey": "alices-gateway-key",
    },
    "bob": {
      "command": "npx",
      "args": ["-y", "@notionhq/notion-mcp-server"],
      "env": { "NOTION_TOKEN": "ntn_bobs_token" },
      "apiKey": "bobs-gateway-key",
    },
  },
}
chmod 600 users.json
npx -y supergateway --config users.json
  • Alice's client uses http://localhost:8000/alice/mcp with her key. Only her key is accepted there, and only Bob's at /bob/mcp.
  • Each user's server process gets that user's env on top of the gateway's own environment. So the tokens are written in the file, not passed as ${VAR}: a variable in the gateway's environment would reach every user's server.
  • Adding a user means editing the file and restarting. For users who come and go, run a gateway per user instead (a process or container each, with --stdio, --apiKey and only that user's token in its environment) and route to it.
  • No flag or config key takes credentials from a client's request yet. From code, the serverProcess hook can (next release).

Behind a reverse proxy

When clients reach the gateway over HTTPS on a public name. Here nginx serves it at https://mcp.example.com/files/:

npx -y supergateway \
    --stdio "npx -y @modelcontextprotocol/server-filesystem ./my-folder" \
    --outputTransport streamableHttp --host 127.0.0.1 --port 8000 --apiKey "$MCP_API_KEY"
map $http_upgrade $connection_upgrade {
  default upgrade;
  ''      '';
}

server {
  listen 443 ssl;
  server_name mcp.example.com;
  # ssl_certificate and ssl_certificate_key as usual

  location /files/ {
    proxy_pass http://127.0.0.1:8000/;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header Upgrade $http_upgrade;          # for WebSocket output
    proxy_set_header Connection $connection_upgrade;
    proxy_buffering off;                             # send each SSE event at once
    proxy_cache off;
    proxy_read_timeout 1h;                           # keep streams and long calls open
    proxy_send_timeout 1h;
  }
}

Clients use https://mcp.example.com/files/mcp.

  • Buffering off matters for SSE output and for Streamable HTTP's event streams: with it on, events wait in nginx. nginx's default timeout of 60 seconds would end idle streams and long calls.
  • SSE output under a path needs --baseUrl with that path: --baseUrl https://mcp.example.com/files makes the message endpoint /files/message. Only its path is used (see Troubleshooting).
  • --host 127.0.0.1 keeps the gateway reachable only through the proxy.
  • Web pages. Clients that aren't browsers are never affected by the gateway's browser checks. Without a key, connections from the proxy arrive on loopback, so a web page served at mcp.example.com that calls the gateway there is refused (403, Forbidden: host not allowed) until --cors lists its origin: --cors https://mcp.example.com. See Security.

Docker and Kubernetes

When the gateway runs in a container. Pin a version tag (see Running with Docker):

docker run -d --name mcp-fetch -p 8000:8000 -e SUPERGATEWAY_API_KEY="$MCP_API_KEY" \
  supercorp/supergateway:4.4.0-uvx \
  --stdio "uvx mcp-server-fetch" --outputTransport streamableHttp \
  --healthEndpoint /healthz
  • The tags are <version>, <version>-uvx and <version>-deno, and from the next release <version>-debian, <version>-uvx-debian and <version>-deno-debian for servers that need glibc.
  • The gateway listens on every interface unless --host says otherwise, which a container needs. --host 127.0.0.1 inside a container would accept connections from that container only.
  • docker stop sends SIGTERM. The gateway stops each server process (SIGTERM, then SIGKILL after 5 seconds) and exits with code 0, within Docker's default 10 seconds.
  • Started without -i, the container has no stdin to close, so the gateway keeps running (see Shutdown).

In Kubernetes, the same image with a readiness probe that checks the server (from the next release, the Helm chart sets this up from a config file):

apiVersion: v1
kind: Secret
metadata:
  name: mcp-fetch
stringData:
  api-key: change-me
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mcp-fetch
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mcp-fetch
  template:
    metadata:
      labels:
        app: mcp-fetch
    spec:
      containers:
        - name: supergateway
          image: supercorp/supergateway:4.4.0-uvx
          args:
            - --stdio
            - uvx mcp-server-fetch
            - --outputTransport
            - streamableHttp
            - --host
            - 0.0.0.0
            - --port
            - '8000'
            - --healthEndpoint
            - /ready
            - --healthCheck
            - server
          env:
            - name: SUPERGATEWAY_API_KEY
              valueFrom:
                secretKeyRef:
                  name: mcp-fetch
                  key: api-key
          ports:
            - containerPort: 8000
          readinessProbe:
            httpGet:
              path: /ready
              port: 8000
            periodSeconds: 10
            timeoutSeconds: 15
          livenessProbe:
            tcpSocket:
              port: 8000
            periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
  name: mcp-fetch
spec:
  selector:
    app: mcp-fetch
  ports:
    - port: 80
      targetPort: 8000

Clients in the cluster use http://mcp-fetch/mcp with the key.

  • Readiness: with --healthCheck server, /ready starts the server, initializes and pings it, and answers 503 with the reason while it can't. A check can take up to 10 seconds, hence timeoutSeconds: 15. The answer is reused for 10 seconds, so the probe starts at most one server per 10 seconds. Health endpoints never need the key.
  • Liveness is a TCP check: with one server, every health endpoint checks the server, and a failing server shouldn't restart the pod. With several servers in a config file, a top-level healthEndpoint answers for the gateway alone and can be the liveness probe.
  • Shutdown: Kubernetes sends SIGTERM and waits 30 seconds by default; the gateway needs at most about 5.
  • Replicas: SSE connections, stateful sessions and 2026-07-28 continuations live in one pod's memory. With more than one replica, each client must keep reaching the same pod.

Docker Compose

The same container with Compose, a health check, and the key in a file rather than the environment:

services:
  mcp-fetch:
    image: supercorp/supergateway:4.4.0-uvx
    command:
      - --stdio
      - uvx mcp-server-fetch
      - --outputTransport
      - streamableHttp
      - --healthEndpoint
      - /healthz
      - --healthCheck
      - server
    environment:
      SUPERGATEWAY_API_KEY_FILE: /run/secrets/mcp_api_key
    secrets:
      - mcp_api_key
    ports:
      - '8000:8000'
    restart: unless-stopped
    healthcheck:
      test:
        - CMD
        - node
        - -e
        - "fetch('http://127.0.0.1:8000/healthz').then((r) => process.exit(r.ok ? 0 : 1), () => process.exit(1))"
      interval: 30s
      timeout: 15s
      start_period: 10s
      retries: 3

secrets:
  mcp_api_key:
    file: ./mcp_api_key.txt
(umask 077; openssl rand -hex 32 > mcp_api_key.txt)
docker compose up -d
docker compose ps   # STATUS turns to "healthy"
  • The check uses node, which every image has; they have no curl, and the Debian ones no wget. The double quotes around the script matter: unquoted, YAML reads r.ok ? 0 : 1 as a mapping.
  • --healthCheck server makes "healthy" mean the server starts and answers; while it can't, the endpoint answers 503 with the reason and the container turns unhealthy. Docker doesn't restart an unhealthy container. It shows in docker compose ps, and another service can wait for it with depends_on: { mcp-fetch: { condition: service_healthy } }. restart: unless-stopped restarts the gateway if it exits.
  • The key is read from the file at startup. To rotate it, add the new key on a line of its own, restart, move clients over, then remove the old one.

systemd

On a Linux server, run the standalone executable as a service. The key stays in a root-only file, handed to the service with LoadCredential:

curl -fsSL https://github.com/supercorp-ai/supergateway/releases/latest/download/supergateway-linux-x64.tar.gz \
  | sudo tar -xz -C /usr/local/bin supergateway
sudo install -d -m 700 /etc/supergateway
sudo sh -c 'umask 077; openssl rand -hex 32 > /etc/supergateway/api-key'

/etc/systemd/system/supergateway.service:

[Unit]
Description=Supergateway: mcp-server-fetch over Streamable HTTP
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/local/bin/supergateway --stdio "uvx mcp-server-fetch" \
    --outputTransport streamableHttp --port 8000 --healthEndpoint /healthz
LoadCredential=api-key:/etc/supergateway/api-key
Environment=SUPERGATEWAY_API_KEY_FILE=%d/api-key
Restart=on-failure
RestartSec=5
TimeoutStopSec=15

# A user of its own, created while the service runs; uv's cache in /var/cache.
DynamicUser=yes
CacheDirectory=supergateway
Environment=HOME=/var/cache/supergateway

NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectKernelLogs=yes
ProtectControlGroups=yes
ProtectClock=yes
ProtectHostname=yes
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
LockPersonality=yes
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
CapabilityBoundingSet=
SystemCallArchitectures=native

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now supergateway
journalctl -u supergateway -f
  • The server's runtime must be installed system-wide, here uvx in /usr/local/bin or /usr/bin; ProtectHome hides anything under /home. HOME points at the cache directory, the one place the service can write, so uv and npx keep their downloads there between restarts. Give servers more places to write with ReadWritePaths=.
  • The hardening leaves out MemoryDenyWriteExecute, which stops Node's and Python's JIT, and PrivateNetwork, IPAddressDeny and RestrictAddressFamilies=none, which would cut off servers that call the internet. systemd-analyze security supergateway rates the unit above at 3.0 ("OK").
  • LoadCredential and %d need systemd 248 or newer (Debian 12, Ubuntu 22.04, RHEL 9). Credentials are readable by the service alone, and never appear in systemctl show.
  • Stopping sends SIGTERM; the gateway stops each server process and exits with code 0. Restart=on-failure restarts it if it exits with an error, such as the port being in use. A server that exits doesn't stop the gateway: the next client gets a new one (see Coming from 3.x).
  • Started by systemd, stdin is /dev/null, so the gateway keeps running (see Shutdown).

Windows service

A Windows service must answer the Service Control Manager, and supergateway.exe is a console program that doesn't, so sc.exe create with it alone fails to start (error 1053). WinSW (free, MIT) is a small wrapper that does: it runs the program as a service, restarts it when it fails, stops it with Ctrl+C and writes its logs.

In C:\supergateway, put supergateway.exe from the win-x64 archive, WinSW-x64.exe from WinSW's releases renamed to supergateway-service.exe, and beside it supergateway-service.xml:

<service>
  <id>supergateway</id>
  <name>Supergateway</name>
  <description>MCP servers over HTTP</description>
  <executable>cmd.exe</executable>
  <arguments>/c C:\supergateway\supergateway.exe --config C:\supergateway\servers.json &lt; NUL</arguments>
  <env name="SUPERGATEWAY_API_KEY_FILE" value="C:\supergateway\api-key.txt" />
  <onfailure action="restart" delay="10 sec" />
  <stopparentprocessfirst>true</stopparentprocessfirst>
  <stoptimeout>15 sec</stoptimeout>
  <log mode="roll-by-size" />
</service>

C:\supergateway\servers.json:

{
  "port": 8000,
  "healthEndpoint": "/healthz",
  "outputTransport": "streamableHttp",
  "mcpServers": {
    "fetch": {
      "command": "C:\\Users\\me\\.local\\bin\\uvx.exe",
      "args": ["mcp-server-fetch"],
    },
  },
}

In an Administrator PowerShell:

$bytes = New-Object byte[] 32
[Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($bytes)
-join ($bytes | ForEach-Object { '{0:x2}' -f $_ }) | Set-Content C:\supergateway\api-key.txt
New-NetFirewallRule -DisplayName Supergateway -Direction Inbound -Protocol TCP -LocalPort 8000 -Action Allow
C:\supergateway\supergateway-service.exe install
C:\supergateway\supergateway-service.exe start
  • < NUL: a service has no stdin, and the gateway stops when its stdin ends. cmd.exe gives it NUL instead, as < /dev/null does on Linux and macOS (see Shutdown).
  • The config file keeps the command line free of quotes, which cmd.exe /c would otherwise need care with. Clients use http://<host>:8000/fetch/mcp.
  • The service runs as LocalSystem, which doesn't have your user's PATH: give command as a full path, or install the server's runtime for all users. Its downloads go under C:\Windows\System32\config\systemprofile.
  • Stopping sends Ctrl+C. stopparentprocessfirst lets the gateway end its servers' process trees itself and exit with code 0 before WinSW ends anything left.
  • Logs are supergateway-service.out.log and supergateway-service.err.log beside the XML.
  • The firewall rule lets other machines reach the port; leave it out if only this machine's clients use the gateway.

Render (free)

The button creates the service in render.yaml on Render's free plan: the published 4.4.0-uvx image, serving mcp-server-fetch over Streamable HTTP, with a generated key. No payment method is needed.

  • Clients use https://<service>.onrender.com/mcp with the key, which is SUPERGATEWAY_API_KEY on the service's Environment page.
  • Another server: change the service's Docker Command in the dashboard, or copy render.yaml into a repository of your own and change dockerCommand. It starts with supergateway because Render runs it in place of the image's entrypoint.
  • Port: Render sends traffic to port 10000, its PORT. The gateway doesn't read PORT, so the command passes --port 10000.
  • Free web services stop after 15 minutes without traffic and take about a minute to start on the next request. They have 512 MB and a tenth of a CPU, which is enough for a light server or two. Sessions don't survive a stop: clients get 404 for their session and start a new one. A workspace has 750 free hours a month.
  • Health: Render checks /healthz before sending traffic and while the service runs.

From your own program

When a program starts the gateway: a test suite, a desktop app, an agent. With the library (next release), there is no free-port helper or log to read:

import { startSupergateway } from 'supergateway'

const gateway = await startSupergateway({
  port: 0, // any free port
  host: '127.0.0.1',
  config: {
    outputTransport: 'streamableHttp',
    mcpServers: {
      fetch: { command: 'uvx', args: ['mcp-server-fetch'] },
      git: { command: 'uvx', args: ['mcp-server-git'] },
    },
  },
})

for (const { name, url } of gateway.servers) console.log(name, url)
// fetch http://127.0.0.1:53124/fetch/mcp
// git http://127.0.0.1:53124/git/mcp

process.on('SIGTERM', async () => {
  await gateway.close() // stops every server process
  process.exit(0)
})

See From code for the options, status and hooks.

With 4.4.0, start the command instead, and pass your program's PID so the gateway stops if your program dies first:

npx -y supergateway@4.4.0 --config servers.json --host 127.0.0.1 --port 8000 \
    --healthEndpoint /healthz --exitWithProcess "$$" < /dev/null

Wait until /healthz answers ok before connecting. From the next release, --port 0 also works here: the Listening on port N line gives the port, and with --logFormat json the line with "event": "listening" gives each server's URL as data (see --logFormat).

Using with Claude Desktop (SSE → stdio mode)

Claude Desktop can use Supergateway’s SSE→stdio mode.

NPX-based MCP Server Example

{
  "mcpServers": {
    "supermachineExampleNpx": {
      "command": "npx",
      "args": [
        "-y",
        "supergateway",
        "--sse",
        "https://mcp-server-ab71a6b2-cd55-49d0-adba-562bc85956e3.supermachine.app"
      ]
    }
  }
}

Docker-based MCP Server Example

{
  "mcpServers": {
    "supermachineExampleDocker": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "supercorp/supergateway",
        "--sse",
        "https://mcp-server-ab71a6b2-cd55-49d0-adba-562bc85956e3.supermachine.app"
      ]
    }
  }
}

Using with Cursor (SSE → stdio mode)

Cursor can also integrate with Supergateway in SSE→stdio mode. The configuration is similar to Claude Desktop.

NPX-based MCP Server Example for Cursor

{
  "mcpServers": {
    "cursorExampleNpx": {
      "command": "npx",
      "args": [
        "-y",
        "supergateway",
        "--sse",
        "https://mcp-server-ab71a6b2-cd55-49d0-adba-562bc85956e3.supermachine.app"
      ]
    }
  }
}

Docker-based MCP Server Example for Cursor

{
  "mcpServers": {
    "cursorExampleDocker": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "supercorp/supergateway",
        "--sse",
        "https://mcp-server-ab71a6b2-cd55-49d0-adba-562bc85956e3.supermachine.app"
      ]
    }
  }
}

Note: Although the setup supports sending headers via the --header flag, if you need to pass an Authorization header (which typically includes a space, e.g. "Bearer 123"), you must use the --oauth2Bearer flag due to a known Cursor bug with spaces in command-line arguments.

Troubleshooting

--baseUrl host is not used

In stdio→SSE mode only the path of --baseUrl reaches clients: --baseUrl https://mcp.example.com/gateway makes the message endpoint /gateway/message, and clients post to the host they connected through. Clients that need an absolute endpoint URL, such as Copilot Studio, should use --outputTransport streamableHttp.

Why MCP?

Model Context Protocol standardizes AI tool interactions. Supergateway converts MCP stdio servers into SSE or WS services, simplifying integration and debugging with web-based or remote clients.

Additional resources

  • Superargs - provide arguments to MCP servers during runtime.

Contributors

Contributing

Issues and PRs welcome: see CONTRIBUTING.md. For help, ask on Discord (SUPPORT.md); report security issues privately (SECURITY.md). Accessibility: ACCESSIBILITY.md.

Tests

Supergateway is tested with the Node Test Runner.

To run the suite locally you need Node 24+. Using nvm you can install and activate it with:

nvm install 24
nvm use 24
npm install
npm run build
npm test

The tests/helpers/mock-mcp-server.js script provides a local MCP server so all tests run without network access.

Two more checks compare this build with the last release, and need the network to fetch it. CI runs both on every pull request:

npm run test:versions   # the same client against the release and this build, side by side
npm run test:released   # the release's own end-to-end tests, run against this build

A difference that is meant is written down with its reason in tests/crossVersion.intended.ts or tests/releasedTests.intended.json; any other fails.

License

MIT License

排名相邻
同类项目

AI Rank iPhone 版

随时追踪 AI 模型榜单

在 App Store 下载