
How to Deploy an MCP Server with Docker
Building an MCP server is only the first step. To make it accessible to AI applications, you need to deploy it in an environment that supports remote connections.
Quick answer: How do you deploy an MCP server?
You can deploy an MCP server by building your application, configuring Streamable HTTP transport, packaging it with Docker, and running it on a server or cloud platform.
With NitroStack, you can create a multi-stage Docker image, configure the server to listen on 0.0.0.0, use port 3000, and run it over HTTP. Your default MCP endpoint will be /mcp.
What is MCP server deployment?
MCP server deployment is the process of running a Model Context Protocol server in an environment where compatible AI applications can connect to its tools and resources.
A local MCP server typically runs on your development machine. A remotely hosted MCP server requires an accessible network endpoint, appropriate transport configuration, and production infrastructure.
Docker provides a convenient way to package and run your MCP server consistently across different environments.
Why use Docker to deploy an MCP server?
Docker packages your application, dependencies, and compiled output into a container image.
For NitroStack, the multi-stage Docker build:
- Installs project dependencies.
- Compiles TypeScript into
dist/. - Builds UI widgets into
src/widgets/out, when present. - Installs production dependencies in the runtime image.
- Starts the compiled MCP server.
This makes the same container image usable across local development and supported cloud infrastructure.
How to deploy an MCP server using Docker
For this walkthrough, we'll use NitroStack's Docker deployment configuration.
Step 1: Create your Dockerfile
Create a Dockerfile in your NitroStack project root:
dockerfileFROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build FROM node:20-alpine WORKDIR /app ENV NODE_ENV=production \ HOST=0.0.0.0 \ PORT=3000 \ MCP_TRANSPORT_TYPE=http COPY package*.json ./ RUN npm ci --omit=dev COPY --from=builder /app/dist ./dist COPY --from=builder /app/src/widgets/out ./src/widgets/out USER node EXPOSE 3000 HEALTHCHECK --interval=30s --timeout=3s --start-period=10s \ CMD wget -qO- http://localhost:3000/mcp/health || exit 1 CMD ["node", "dist/index.js"]
If your project doesn't include a src/widgets directory, remove the corresponding COPY instruction.
Step 2: Configure environment variables
Configure these settings for your Docker deployment:
envNODE_ENV=production HOST=0.0.0.0 PORT=3000 MCP_TRANSPORT_TYPE=http
HOST=0.0.0.0 allows connections from outside the container. MCP_TRANSPORT_TYPE=http configures NitroStack to use HTTP-only transport.
Keep API keys and database credentials outside your Dockerfile.
Step 3: Build the Docker image
Run:
bashdocker build -t my-mcp-server .
This compiles your application and creates the container image.
Step 4: Run the MCP server
Start the container:
bashdocker run -d \ --name mcp-server \ -p 3000:3000 \ my-mcp-server
Your MCP server will be accessible locally at:
texthttp://localhost:3000/mcp
Step 5: Verify your deployment
NitroStack provides a health endpoint:
bashcurl http://localhost:3000/mcp/health
A successful response looks similar to:
json{ "status": "ok", "transport": "streamable-http", "sessions": 0, "uptime": 4.2 }
You can inspect container logs using:
bashdocker logs mcp-server
Finally, connect an MCP-compatible client and test tool discovery and execution.
How do you deploy an MCP server with Docker Compose?
If your MCP server needs a database, Docker Compose lets you run both services together.
Create a docker-compose.yml file:
yamlservices: mcp-server: build: . ports: - "3000:3000" env_file: .env.production depends_on: - database restart: unless-stopped database: image: postgres:16-alpine environment: POSTGRES_DB: myapp POSTGRES_USER: app POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} volumes: - db-data:/var/lib/postgresql/data volumes: db-data:
Run:
bashdocker compose up -d
The MCP server can access PostgreSQL using database as its hostname within the Compose network.
For production, configure database readiness checks, backups, and secure secret management.
Common MCP server deployment problems
Connection refused: Check that HOST=0.0.0.0 is configured and the Docker port mapping is correct.
Widgets not rendering: Confirm that the widget build completes and src/widgets/out is copied into the runtime image.
Container exits unexpectedly: Run docker logs mcp-server to identify startup errors.
Health check fails: Verify that the application is running and /mcp/health is accessible.
MCP server deployment: Quick reference
| Configuration | NitroStack default |
|---|---|
| Transport | Streamable HTTP |
| MCP endpoint | /mcp |
| Default port | 3000 |
| Container host | 0.0.0.0 |
| Health endpoint | /mcp/health |
| Build command | docker build -t my-mcp-server . |
| Run command | docker run -d --name mcp-server -p 3000:3000 my-mcp-server |
Frequently asked questions
How do you deploy an MCP server?
Build your MCP application, configure a supported transport such as Streamable HTTP, package it with Docker, and run it on a server or cloud platform.
Can you deploy an MCP server using Docker?
Yes. Docker packages the MCP application and its dependencies into a portable container image that can run on compatible infrastructure.
How do I host an MCP server?
You can host an MCP server on your own infrastructure or a cloud platform that supports your application. For remote connections, configure the appropriate HTTP transport, network access, and security.
What port does NitroStack use for Docker deployment?
NitroStack uses port 3000 by default. You can change it using the PORT environment variable.
What is the NitroStack MCP endpoint?
The default Streamable HTTP endpoint is /mcp.
How do I check whether my MCP server is running?
Use NitroStack's /mcp/health endpoint and inspect your Docker container logs.
Can NitroStack run with PostgreSQL in Docker?
Yes. You can run NitroStack and PostgreSQL as separate services using Docker Compose.
Deploy your MCP server with NitroStack
Docker provides a consistent way to package and run MCP servers. NitroStack makes this workflow practical with its SDK, production configuration, Streamable HTTP support, and built-in health endpoint.
Ready to deploy?
Build your MCP server with NitroStack and take it from development to production.
Tags

Sharvari Raut
Author
A blog poet ✍🏻