Deploying a generated server
Every project mcpgen emits is deploy-ready out of the box. Alongside the source it writes a full deploy kit:
| File | Purpose |
|---|---|
Dockerfile | Hardened multi-stage build, with a HEALTHCHECK on /healthz. |
.dockerignore | Keeps the build context (and image) small. |
docker-compose.yml | Local Compose service over the HTTP transport. |
fly.toml | Fly.io app config (build, env, /healthz check). |
render.yaml | Render Blueprint (Docker build, health check, secret env vars). |
railway.json | Railway config (Dockerfile build, /healthz check). |
.env.example | Every env var the server reads, documented. |
The server speaks Streamable HTTP at /mcp and answers a liveness probe at
/healthz ({"status":"ok",...}).
Deploy targets
Docker / Compose
docker build -t my-server .
docker run -p 3000:3000 --env-file .env my-server
# or:
docker compose up --build
curl http://localhost:3000/healthzProduction hardening
The generated server follows the MCP SDK’s guidance for remote transports:
- TLS — terminate HTTPS at the platform edge (Fly/Render/Railway do this for you). Tokens then never travel in cleartext.
- DNS-rebinding protection — set
MCPGEN_ALLOWED_HOSTSto your public domain(s). The Streamable HTTP transport rejects requests whoseHostheader isn’t in the allow-list. - CORS — set
MCPGEN_CORS_ORIGINto your client’s origin instead of*. - OAuth 2.1 — when the source uses OAuth/bearer auth, the server serves
/.well-known/oauth-protected-resource(RFC 9728). PointMCPGEN_OAUTH_RESOURCEandMCPGEN_OAUTH_AUTH_SERVERat your deployment.
Want to smoke-test the image before shipping? The repo’s opt-in docker-smoke
test (MCPGEN_DOCKER_SMOKE=1) actually docker builds a generated server and
polls /healthz.
Deploying mcpgen itself
The CLI publishes to npm as mcpgenx and installs the mcpgen command (so
npx mcpgenx works with no install), and the web UI + API ship as Docker images. The full
guide lives in the repo at
docs/deployment.md.
Last updated on