To use kubefwd with an MCP-compatible AI client, you must first start the kubefwd process with the API enabled. It is highly recommended to use the --tui flag to visually monitor AI-driven activity and use sudo -E to ensure your KUBECONFIG environment variable is preserved.
Important: You must set a known API key using the KUBEFWD_API_KEY environment variable. If left unset, kubefwd generates a random key that the MCP bridge cannot discover, resulting in 401 errors for all tool calls.
# Set a known key so the MCP bridge can authenticate
export KUBEFWD_API_KEY=my-known-key
# Start in idle mode with API (waits for MCP commands)
sudo -E kubefwd
# OR start with TUI to monitor AI-driven activity (Recommended)
sudo -E kubefwd --tui
# OR pre-forward a namespace and enable API
sudo -E kubefwd svc -n default --api