Development Environment - cturner8/kube-mcp GitHub Wiki
This guide helps you set up a reliable development environment for kube-mcp. You can use the provided devcontainers or set things up manually.
Requirements
Required
- Go 1.25.x
- Docker (or Podman) with BuildKit enabled
- A Kubernetes cluster for development (kind, minikube, k3d, or remote)
- Git
Optional but recommended
- kubectl (tested with 1.29+)
- Helm 3.x
- VS Code + Dev Containers extension
- k9s (already included in the devcontainers)
Quickstart: devcontainer
Two devcontainer variants are provided under the .devcontainer directory:
k8s:- kubectl
- helm
- k9s
- connect to an existing cluster (no embedded Minikube).
minikube:- kubectl
- helm
- k9s
- minikube
- docker-in-docker
- boots a local Minikube inside the container with dashboard, metrics-server, and ingress enabled.
Steps (VS Code):
- Install Docker and the βDev Containersβ extension.
- Open the repo folder in VS Code, then Reopen in Container either from the Command Palette or the Remote Icon in bottom left corner.
- Choose the variant you want (
minikubeork8s).minikubewill runminikube start --addons=dashboard,metrics-server,ingresson start.
- Ports
8000/8080/8443are forwarded by default; adjust as needed in the devcontainer config.
Manual environment setup
- Install prerequisites
- Go 1.25.x
- Docker/Podman
- kubectl
- Helm
- preferred local cluster tool (kind/minikube/k3d).
- Clone the repository
git clone https://github.com/cturner8/kube-mcp.git cd kube-mcp - Fetch Go dependencies and run a quick check
cd api go mod download go build . - (Optional) Lint Helm charts
helm lint charts/kube-mcp - Ensure your kubeconfig points to the dev cluster you plan to use
kubectl config get-contexts kubectl config use-context <your-dev-context>
Create a dev cluster
If you don't have an existing Kubernetes cluster, you'll need to create a local one for development and testing. Choose the tool that best fits your workflow:
Using minikube
Minikube is the easiest option for beginners and is included in the minikube devcontainer. It creates a single-node Kubernetes cluster inside a VM or using Docker.
Quick start:
minikube start --addons=dashboard,metrics-server,ingress
This enables the dashboard, metrics server for monitoring, and ingress controller β all useful for kube-mcp development.
Using kind
kind (Kubernetes in Docker) is ideal if you're familiar with Docker and want a lightweight, multi-node cluster that works well in CI/CD pipelines.
Quick start with port forwarding for kube-mcp:
cat <<EOF | kind create cluster --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
EOF
This configuration forwards HTTP and HTTPS ports, useful if you're testing kube-mcp behind an ingress.
Using k3d
k3d wraps k3s (lightweight Kubernetes) in Docker, offering a good balance between simplicity and features. It starts faster than minikube and is more configurable than basic kind setups.
Quick start:
k3d cluster create kube-mcp-dev --port 8080:80@loadbalancer --port 8443:443@loadbalancer
This creates a cluster named kube-mcp-dev with load balancer port forwarding.
Configuration for local development
The server reads configuration from flags or environment variables. Key settings (required):
KUBE_MCP_BASE_URL(required) β base URL the app is accessed from.KUBE_MCP_OIDC_ISSUER_URL(required) β OIDC issuer.KUBE_MCP_OIDC_CLIENT_ID(required) β client ID.
Additional optional settings:
KUBE_MCP_ALLOWED_ORIGINSβ comma-separated CORS origins.KUBE_MCP_PORTβ defaults to 9000.KUBE_MCP_LOG_LEVELβ debug|info|warn|error (default info).KUBE_MCP_ALLOWED_TOOLS/KUBE_MCP_DISALLOWED_TOOLSβ comma-separated allow/deny lists (only one may be set).KUBE_MCP_OIDC_SCOPESβ comma-separated scopes (default: openid).KUBE_MCP_OIDC_SIGNING_METHODβ HS256 or RS256.
Run the API locally (out of cluster)
cd kube-mcp/api
go run . \
--base-url "http://localhost:9000" \
--oidc-issuer-url "https://auth.localhost:8443" \
--oidc-client-id "00000000-0000-0000-0000-000000000000" \
--out-of-cluster \
- By default the kubeconfig is loaded from
$HOME/.kube/config, use the--kubeconfigflag to use a different kubeconfig. - Add
--allowed-toolsor--disallowed-toolsif you need to constrain tool access. - Override the port with
--portorKUBE_MCP_PORT. - Add allowed origins if accessing from the browser (useful for MCP inspector).
Verify your setup
- Go toolchain:
go version - Docker:
docker info - kubectl:
kubectl version --client --short - Helm:
helm version --short - Cluster reachable:
kubectl get nodes
Understanding the codebase
Before diving into development, familiarise yourself with the project structure:
kube-mcp/
βββ api/ # Go application source code
β βββ main.go # Application entry point and server startup
β βββ config/ # Configuration management (CLI flags, environment variables)
β βββ server/ # HTTP server implementation and MCP protocol handlers
β βββ kubernetes/ # Kubernetes client setup and API interactions
β βββ tools/ # MCP tool implementations (one file per tool)
βββ charts/ # Helm deployment configuration
β βββ kube-mcp/ # Main Helm chart with templates and values
βββ .devcontainer/ # VS Code development container configurations
β βββ k8s/ # Devcontainer for connecting to existing clusters
β βββ minikube/ # Devcontainer with embedded Minikube
βββ .github/workflows/ # GitHub Actions CI/CD automation
βββ test.yml # Build and test workflow
βββ build.yml # Container image build workflow
βββ helm.yml # Helm chart publication workflow
Key directories
- api/ β Contains the Go application. Most development happens here. The entry point is
main.go, which initialises the HTTP server and loads configuration. - api/tools/ β Each MCP tool (e.g.,
list_pods,get_deployment) has its own file following a consistent implementation pattern. - charts/ β Helm templates and values for deployment. Modify when changing deployment configuration or adding new Helm features.
- .devcontainer/ β Pre-configured development environments for VS Code. Contains both a standalone Minikube variant and a variant for connecting to existing clusters.
- .github/workflows/ β Automated testing and release workflows. Typically read-only during development, but useful to understand for CI/CD troubleshooting.
Next steps
- Explore the
api/main.gofile to understand server initialisation and configuration loading. - Review
api/tools/to see how MCP tools are implemented.