Deploying to Docker
This guide covers deploying a Model Context Protocol server on Docker using the stdio or streamable-http transport. This deployment model is intermediate difficulty.
Prerequisites
- Docker 24+
- MCP server source code
Deployment Steps
- Prepare your server build. Ensure your MCP server builds cleanly:
npm run build - Write the configuration.
FROM node:20-alpine WORKDIR /app COPY package*.json ./ RUN npm ci --omit=dev COPY . . ENV NODE_ENV=production EXPOSE 3000 CMD ["node", "server.js"] - Set environment variables. Never bake secrets into container images or deployment configs. Use the platform's secret management system.
- Deploy and verify. After deployment, test the Streamable HTTP endpoint responds with a valid MCP response.
- Configure your client. Add the deployed server URL to your client configuration.
Production Security Checklist
- Serve over HTTPS only — never expose MCP servers on plain HTTP.
- Set
NODE_ENV=productionto disable debug output. - Apply network egress rules to limit what the server can reach.
- Enable request logging and ship logs to a central SIEM.