Keeps the verified results (healthz 200, 401 without a key, wrong key 401, unknown path 401) and the EADDRINUSE/port-8080 finding, but uses a placeholder hostname instead of the real one.
12 KiB
mcp-maigret behind Surfshark WireGuard — public HTTPS endpoint
What this stack is
| Service | Role |
|---|---|
gluetun |
Owns the network namespace and the Surfshark WireGuard tunnel. The reverse proxy reaches it on port 8080. |
maigret-mcp |
Runs inside Gluetun's namespace. supergateway wraps the stdio MCP server as Streamable HTTP on :8080/mcp, which is what your domain serves. |
Every outbound request maigret makes to the hundreds of sites it checks leaves through Surfshark, because the container lives in Gluetun's network namespace.
Files
| File | Change |
|---|---|
docker-compose.yml |
Added — the stack |
.env.example |
Added — values you supply (.env is gitignored upstream) |
Dockerfile |
Modified — one line: RUN npm install -g supergateway@4.2.2 |
The Dockerfile change is required because the server speaks stdio only
(StdioServerTransport is its only transport). Baking the gateway in means a container
restart never depends on the npm registry being reachable. Revert that line and the
gateway must be supplied another way.
1. Get the Surfshark WireGuard keypair
Surfshark's WireGuard is not username/password — it needs a registered keypair.
- Surfshark account → VPN → Manual setup → Desktop or mobile → WireGuard
- "I don't have a keypair" → name it → Generate a new keypair
- Private key →
WIREGUARD_PRIVATE_KEY(32-byte base64, ends with=) - Download the config for any location, read its
Addressline, take the IPv4 part (e.g.10.14.0.2/16) →WIREGUARD_ADDRESSES
The Address value is the same for every Surfshark server with that keypair; it does not
change with SERVER_COUNTRIES. Ignore the rest of the config file.
2. Deploy — a Git repo is required
This stack cannot go into "Docker Compose Empty":
- No image is published — Docker Hub
w0h1v/mcp-maigretreturns 404, GHCR returns 403. CI only runs a localdocker build; the npm workflow publishes the package. - So the compose carries
build:, and a "Docker Compose Empty" resource stores compose text only — it has no checkout to build from.
Fork → Application
- Fork/push this repo to your Gitea.
- Coolify → + New → Public Repository (or Gitea source) → your fork.
- Build Pack:
Docker Compose - Base Directory:
/, Docker Compose Location:/docker-compose.yml - Environment Variables:
WIREGUARD_PRIVATE_KEY— your private keyWIREGUARD_ADDRESSES— e.g.10.14.0.2/16SERVICE_PASSWORD_64_MCPAPIKEY— leave it; Coolify generates and stores it- optional:
SERVER_COUNTRIES(defaultAustria),TZ
- Deploy
DNS first, then the domain
Create the A record before attaching the domain, or the certificate cannot issue:
maigret.example.com A <your Coolify host IP>
Then Configuration → Domains → Add:
| Field | Value |
|---|---|
| Domain | https://maigret.example.com |
| Service | gluetun ← not maigret-mcp |
| Port | 8080 |
| Path | /mcp (optional; the route is host-based) |
The domain must point at gluetun, because the app has no IP of its own — it shares
Gluetun's namespace. The proxy resolves gluetun:8080 and the packet lands on
supergateway inside that namespace.
If the route 502s or 404s, enable Configuration → Network → Network attachment → "Connect to the predefined Coolify network".
The compose also carries SERVICE_URL_GLUETUN_8080: "/" so Coolify seeds that domain row
on first parse. That value is only a path — the hostname in the Domains field is what
actually counts. Delete the placeholder row if Coolify creates a random hostname.
Alternative: keep "Docker Compose Empty"
Only if you build and push the image yourself (e.g. to your Gitea registry):
git clone https://github.com/w0h1v/mcp-maigret.git && cd mcp-maigret
docker build -t <registry>/maigret-mcp:1.0.22 .
docker push <registry>/maigret-mcp:1.0.22
Then replace the build: block with image: <registry>/maigret-mcp:1.0.22 and paste the
file into a Docker Compose Empty resource. Note the derived image must still contain
supergateway — the one built from this repo does.
3. Why the compose looks the way it does
entrypoint: ["supergateway"]is required. The image'sENTRYPOINTis["node", "build/index.js"]andcommand:only replacesCMD— so gateway flags would be appended to that node call and the gateway would never start. The stdio server is passed to the gateway as--stdio "node build/index.js"instead.--host 0.0.0.0. The proxy connects from outside the namespace. A gateway bound to127.0.0.1is unreachable through the published route.- Port 8080, not 8000. Gluetun's own HTTP control server listens on 8000 inside the
same namespace, so the gateway cannot bind it — the container crash-loops with
EADDRINUSE: address already in use 0.0.0.0:8000. Gluetun also holds127.0.0.1:53(DNS) and127.0.0.1:9999(health server) there. If you change this port, change all four places:--port,FIREWALL_INPUT_PORTS, theSERVICE_URL_GLUETUN_<PORT>key and the healthcheck URL. --healthCheck server. Makes/healthzactually start the MCP server, initialize and ping it, so a broken child returns 503 instead of a cheerful "ok".SUPERGATEWAY_API_KEYis mandatory in practice. Without it the endpoint is an open OSINT proxy: anyone who finds the hostname can run unlimited username scans from your Surfshark IP. supergateway answers 401 to any request without the key.MAIGRET_RUNNER: local. Thedockermode shells out todocker run, which would start a sibling container on the default bridge — outside this namespace, egressing from the host IP and defeating the VPN entirely. The image bundles maigret 0.6.6.network_mode: service:gluetun— noports:, nonetworks:; Compose rejects both alongside a shared namespace. The app is reachable only through Gluetun.depends_on: gluetun: service_healthy— Gluetun's own probe (/gluetun-entrypoint healthcheck) is the only correct "tunnel is up" signal, so nothing egresses before the tunnel exists.- Gluetun pinned to
v3.41.3— the last stable release (2026-07-30).:latestcurrently resolves to an untagged edge build (2026-11-20, revisioneb3c7ec7).v3/v3.41/v3.41.3are the same digest. stdin_open: true— kept deliberately. The bare stdio server exits 0 immediately when stdin is/dev/null(verified), which exit-loops underrestart: unless-stopped. supergateway survived/dev/nullin testing, but it documents exiting when stdin closes, so an open stdin is the safe configuration and costs nothing.
4. Connect a client
Endpoint: https://maigret.example.com/mcp, header
Authorization: Bearer <SERVICE_PASSWORD_64_MCPAPIKEY> (or X-API-Key: <key>).
The key is under Environment Variables in Coolify, after the first deploy.
{
"mcpServers": {
"maigret": {
"type": "streamable-http",
"url": "https://maigret.example.com/mcp",
"headers": { "Authorization": "Bearer <YOUR_KEY>" }
}
}
}
Clients without native Streamable HTTP support (Claude Desktop) go through mcp-remote:
npx -y mcp-remote https://maigret.example.com/mcp \
--header "Authorization: Bearer <YOUR_KEY>"
Two tools are exposed: search_username and parse_url.
5. Verify after deploy
# 1. liveness — open, no key required
curl -sS https://maigret.example.com/healthz # -> ok
# 2. auth boundary — must be 401
curl -sS -o /dev/null -w '%{http_code}\n' -X POST https://maigret.example.com/mcp \
-H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"c","version":"1"}}}'
# 3. with the key — must be 200 and name the server
curl -sS -X POST https://maigret.example.com/mcp \
-H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
-H "Authorization: Bearer $KEY" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"c","version":"1"}}}'
# 4. the VPN is actually carrying traffic — compare with the host's own IP
docker compose exec gluetun wget -qO- https://api.ipify.org; echo
curl -sS https://api.ipify.org; echo
If (4) prints the same address twice, the tunnel is not carrying traffic — check
docker compose logs gluetun for the WireGuard handshake.
6. Security notes
- This is an OSINT tool that makes thousands of outbound requests per search. Publicly
exposed without a key it will be found and abused, and the abuse lands on your Surfshark
IP. Keep
SUPERGATEWAY_API_KEYset, and rotate it under Environment Variables. - maigret's concurrency is hardcoded upstream as
-n 200(--max-connections), i.e. up to 200 parallel connections. That is aggressive through one tunnel; expect some sites to rate-limit or block. - There is no per-caller rate limit. If you expose this to more than yourself, put one in front (Coolify/Caddy/Cloudflare) — the app has none.
- Use only for authorized research on public information.
7. Verification status
Verified locally (this environment has no Docker daemon):
- Compose schema:
errors=0 warnings=0. qmcgaw/gluetun:v3.41.3exists and is multi-arch;maigret==0.6.6exists on PyPI and is the current release;supergateway@4.2.2exists on npm (engines: node ≥ 20).npm ci && npm run buildsucceeds on Node 24 (the image's base).- The full public path, end to end, running supergateway 4.2.2 against the real server:
/healthz→200 ok;initializewithout a key → 401; with a wrong key → 401; with the right key → 200serverInfo.name = "maigret-server";tools/list→ both tools;tools/call search_username→ the real maigret invocation; an injection attempt (x;rm -rf /) → rejected with a validation error. - The compose's healthcheck command, executed as YAML parses it: exit 0 while the gateway is up, exit 1 while it is down.
- Every maigret flag the server builds (
--txt,--no-color,--no-progressbar,-n,--tags,--folderoutput,--json simple,--parse,--timeout) exists in maigret 0.6.6. Austriais a validSERVER_COUNTRIESvalue (Gluetun's Surfshark data: 363 servers, 100 countries).- Coolify's parser injects
networks:only whennetwork_modeis absent, so this layout is supported rather than tolerated.
Verified against the live deployment (domain not recorded here):
GET /healthz→ 200ok. Because--healthCheck serveris set, that means the MCP server started inside the container and answered a ping — not merely that the gateway is up.POST /mcpwith no key → 401Unauthorized: a valid API key is required.POST /mcpwith a wrong key → 401.- Any unknown path → 401 (only
/healthzis exempt). - TLS certificate valid; DNS resolves.
- The container reached
Node.js v24.22.3, so the image built (apt/pipstage included) andsupergatewayis installed from the Dockerfile line.
Still to confirm by you:
- WireGuard egress —
docker compose exec gluetun wget -qO- https://api.ipify.orgshould differ from the host's own IP. - An authenticated
tools/callwith the realSERVICE_PASSWORD_64_MCPAPIKEY.
8. Known failure hit during the first deploy
The container crash-looped with:
Error: listen EADDRINUSE: address already in use 0.0.0.0:8000
Gluetun's own HTTP control server owns port 8000 inside the shared namespace. That is why the gateway listens on 8080. If you move the port again, change all four places listed in §3.