Skip to content

Google Cloud Run Deployment

The included Dockerfile builds a minimal, static Go binary packaged inside an Alpine/scratch base image (~15MB):

FROM golang:1.25-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /mcp-server .
FROM alpine:3.21
RUN apk --no-cache add ca-certificates
COPY --from=builder /mcp-server /mcp-server
EXPOSE 8080
ENV PORT=8080
ENTRYPOINT ["/mcp-server"]
Terminal window
export GCP_PROJECT="your-project-id"
gcloud run deploy mcp-server \
--source . \
--project $GCP_PROJECT \
--region us-central1 \
--allow-unauthenticated \
--port 8080 \
--memory 256Mi \
--cpu 1 \
--session-affinity

While Streamable HTTP is completely stateless, --session-affinity ensures legacy clients relying on long-lived SSE connections route subsequent requests to the same container instance.