npx supergateway to wrap the MCP Docker image.
Prerequisites
- A valid kubeconfig and a kubectl context pointing to the intended cluster.
dockerinstalled and running (used to run themcp/kubernetes:latestimage).npx(comes with Node.js / npm) to runsupergateway.- Export an environment variable pointing to the kubeconfig file so the MCP container can access cluster metadata and credentials.
Verify kubectl context
Confirm your kubectl context is set to the cluster you want to use and list namespaces to ensure connectivity:Export the kubeconfig file location
Most environments use the default kubeconfig path at$HOME/.kube/config. Export an environment variable that points to the kubeconfig file so it can be mounted into the MCP container:
Start the MCP gateway
We use the npm packagesupergateway (via npx) to run a gateway process that:
- launches the MCP server inside Docker (
mcp/kubernetes:latest), - connects the server’s STDIN/STDOUT to the gateway,
- exposes a streamable HTTP endpoint for MCP requests.
npx -y supergateway --stdio "<command>"— runs the MCP process and tunnels its STDIN/STDOUT to the gateway.- Docker run:
-v ${KUBECONFIG_FILE}:/kubeconfig:romounts your kubeconfig into the container at/kubeconfig(read-only).-e KUBECONFIG=/kubeconfigsets the environment variable inside the container so the MCP server uses the mounted kubeconfig.mcp/kubernetes:latestis the MCP server image.
--outputTransport streamableHttpinstructs the gateway to use a single HTTP connection that can stream JSON chunks in the response.--healthEndpoint /healthzenables the gateway health check endpoint.--port 8000chooses the gateway listening port.
Streamable HTTP uses a single HTTP request/response where the response can be streamed incrementally (JSON chunks). This is a convenient transport for local MCP experimentation. An alternative transport is Server-Sent Events (SSE).
Expected output
When the gateway starts successfully you should see output similar to:Exposed endpoints
Next steps
The MCP gateway is now running and ready to accept MCP-formatted requests over the streamable HTTP endpoint. Interacting with the MCP (for example, sending MCP requests withcurl or a client) will be covered in later lessons.
Additional references: