Docker publishing
Publish your MCP server as a Docker image for easier distribution and deployment
For easier distribution and deployment, you can publish Docker images for your MCP server. This creates a containerized version that can be easily deployed and distributed.
Configure Docker publishing
Section titled “Configure Docker publishing”Under the TypeScript target in your Stainless config, add the mcp_server.publish.docker option:
targets: typescript: options: mcp_server: publish: docker: myorg/my-api-mcpYour Docker image is published to Docker Hub by default. To use a different registry:
targets: typescript: options: mcp_server: publish: docker: image_name: myorg/my-api-mcp registry: ghcr.ioCreate a Docker Hub access token
Section titled “Create a Docker Hub access token”You can create either a Personal Access Token or an Organization Access Token depending on your setup.
Use this for individual Docker Hub accounts or when you don’t have a Docker Team/Business subscription:
- Sign in to your Docker Hub account at hub.docker.com
- Navigate to Account Settings > Security > Personal Access Tokens
- Click Generate new token
- Provide a descriptive token name (e.g., “MCP Server GitHub Actions Publishing”)
- Set access permissions to Read & Write (required for pushing images)
- Click Generate and immediately copy the token
For more details, see Docker’s Personal Access Token documentation.
Use this if you have a Docker Team or Business subscription and want centralized token management:
- Sign in to Docker Hub and navigate to the Admin Console
- Select your organization
- Go to Access tokens > Generate token
- Configure:
- Label and description: “MCP Server GitHub Actions Publishing”
- Expiration date: Set appropriate expiration
- Repository access: Select repositories this token can access
- Access permissions: Enable Read & Write
- Generate and immediately copy the token
Organization Access Tokens provide better security and management features but are incompatible with Docker Desktop. For more details, see Docker’s Organization Access Token documentation.
Add credentials to your production repo
Section titled “Add credentials to your production repo”- Open your production repo in GitHub
- Navigate to Settings > Secrets and variables > Actions > New repository secret
- Add a
DOCKERHUB_TOKENsecret with your access token as the value - Navigate to Settings > Secrets and variables > Actions > Variables tab > New repository variable
- Add a
DOCKERHUB_USERNAMEvariable:- For personal access tokens: use your Docker Hub username
- For organization access tokens: use the organization name
Publish to Docker Hub
Section titled “Publish to Docker Hub”After Docker publishing is configured, the next build generates the necessary Docker assets (Dockerfile, .dockerignore, bin/docker-tags script, and a GitHub Actions workflow) in your SDK.
Versioning follows the same strategy as npm publishing, with exact version tags, latest for stable releases, and pre-release tags like alpha or beta when appropriate. See versioning and releases for details.
Your Docker image is published automatically when a release PR is merged. You can also run the GitHub workflow manually.
Use published Docker images
Section titled “Use published Docker images”Once published, users can run your MCP server using Docker:
# Pull and run the latest versiondocker run --rm -i myorg/my-api-mcp
# Run a specific versiondocker run --rm -i myorg/my-api-mcp:1.2.3
# With environment variablesdocker run --rm -i -e MY_API_KEY=your-api-key myorg/my-api-mcpFor remote deployment with HTTP transport, see Remote deployment.