Kubernetes MCP inside VS Code Remote – WSL
🧩 Prerequisites (you already have most)
- Windows 10/11
- WSL installed with Ubuntu
kubectl,aws,minikubealready working in WSL- VS Code installed on Windows
🟢 STEP 1 — Install Remote – WSL extension
- Open VS Code (Windows)
- Go to Extensions (
Ctrl + Shift + X) - Search for:
WSL - Install it
- Restart VS Code once
🟢 STEP 2 — Open VS Code inside WSL
- Press:
Ctrl + Shift + P - Run:
Remote-WSL: New Window - A new VS Code window opens
- Bottom-left corner must show something like:
WSL: Ubuntu
⚠️ If you still see >< or nothing → you are NOT in WSL.
🟢 STEP 3 — Open your project inside WSL
In the WSL VS Code window:
File → Open Folder- Choose a folder under:
/home/deepak/
Example:/home/deepak/work/k8s
3. Click OK
4. If prompted → “Trust the authors” → Yes
🟢 STEP 4 — Verify you are REALLY in WSL
Open terminal inside VS Code:```
Terminal → New Terminal
Run:```bash
whoami
pwd
Expected:```
deepak
/home/deepak/...
Then:```bash
kubectl config get-contexts
You should see:
- EKS clusters
- minikube
- docker-desktop
✅ This confirms MCP will see the same kubeconfig.
🟢 STEP 5 — (Important) Set a SAFE default context
If you want local testing:```bash
kubectl config use-context minikube
### If you want EKS:```bash
kubectl config use-context arn:aws:eks:ap-south-1:339712902352:cluster/deepak-eks
Verify:```bash
kubectl get ns
---
# 🟢 STEP 6 — Install Node.js inside WSL (required for MCP)
Inside the **WSL VS Code terminal**:```bash
node -v
If command NOT found, install Node LTS:```bash
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejs
Verify:```bash
node -v
npm -v
npx -v
🟢 STEP 7 — Configure MCP Kubernetes server (WSL)
Install MCP Server from below
MCP Server
Open Settings JSON in WSL VS Code:```
Ctrl + Shift + P
→ Preferences: Open Settings (JSON)
Check```json
{
"mcpServers": {
"kubernetes": {
"command": "npx",
"args": [
"-y",
"@kubernetes/mcp-server",
"--log-level",
"4"
]
}
}
}
Save file.
🟢 STEP 8 — Start Kubernetes MCP Server
Ctrl + Shift + P- Run:
MCP: List Server - Select:
kubernetes
Start the server
🟢 STEP 9 — Confirm SUCCESS
In MCP logs you should see:```
Connection state: Running
Waiting for server to respond to initialize
Connection state: Ready
---
# 🟢 STEP 10 — Final sanity test
In VS Code chat / Make sure the Copilot is connected through agent:
Try:```
List all namespaces
or:```
Show nodes in the current cluster
You should get **real Kubernetes output**.
---
# 🔒 Optional (Highly Recommended for EKS)
### Read-only mode (safe for prod):```json
"--read-only"
Disable destructive tools:```json
"--disable-destructive"
Example:```json
"args": [
"-y",
"@kubernetes/mcp-server",
"--read-only",
"--disable-destructive"
]
🧠 Why this setup is CORRECT
- MCP runs where kubectl + certs live
- No Windows ↔ WSL filesystem hacks
-
Works with:
-
EKS
- minikube
- multiple clusters
- This is how AI-driven platform tooling is expected to run