Skip to main content
Welcome back. In this lesson you’ll start a local MCP (Machine Control Plane) gateway that exposes an MCP server as a streamable HTTP endpoint. This guide walks through the prerequisites, verifying your kubeconfig, exporting the environment variable, and running the gateway using npx supergateway to wrap the MCP Docker image.

Prerequisites

  • A valid kubeconfig and a kubectl context pointing to the intended cluster.
  • docker installed and running (used to run the mcp/kubernetes:latest image).
  • npx (comes with Node.js / npm) to run supergateway.
  • Export an environment variable pointing to the kubeconfig file so the MCP container can access cluster metadata and credentials.
Helpful references:

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:
Quickly verify the file exists and the variable is set:

Start the MCP gateway

We use the npm package supergateway (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.
Run the following command to start the gateway:
Key options explained:
  • npx -y supergateway --stdio "<command>" — runs the MCP process and tunnels its STDIN/STDOUT to the gateway.
  • Docker run:
    • -v ${KUBECONFIG_FILE}:/kubeconfig:ro mounts your kubeconfig into the container at /kubeconfig (read-only).
    • -e KUBECONFIG=/kubeconfig sets the environment variable inside the container so the MCP server uses the mounted kubeconfig.
    • mcp/kubernetes:latest is the MCP server image.
  • --outputTransport streamableHttp instructs the gateway to use a single HTTP connection that can stream JSON chunks in the response.
  • --healthEndpoint /healthz enables the gateway health check endpoint.
  • --port 8000 chooses 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 with curl or a client) will be covered in later lessons. Additional references:

Watch Video