Skip to Content
GuidesDeploying

Deploying a generated server

Every project mcpgen emits is deploy-ready out of the box. Alongside the source it writes a full deploy kit:

FilePurpose
DockerfileHardened multi-stage build, with a HEALTHCHECK on /healthz.
.dockerignoreKeeps the build context (and image) small.
docker-compose.ymlLocal Compose service over the HTTP transport.
fly.tomlFly.io app config (build, env, /healthz check).
render.yamlRender Blueprint (Docker build, health check, secret env vars).
railway.jsonRailway config (Dockerfile build, /healthz check).
.env.exampleEvery 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 build -t my-server . docker run -p 3000:3000 --env-file .env my-server # or: docker compose up --build curl http://localhost:3000/healthz

Production 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_HOSTS to your public domain(s). The Streamable HTTP transport rejects requests whose Host header isn’t in the allow-list.
  • CORS — set MCPGEN_CORS_ORIGIN to 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). Point MCPGEN_OAUTH_RESOURCE and MCPGEN_OAUTH_AUTH_SERVER at 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