This document provides detailed instructions for installing the kubectl-mcp-tool, a Kubernetes command-line tool that implements the Model Context Protocol (MCP) to enable AI assistants to interact with Kubernetes clusters.
- PyPI Installation
- Prerequisites
- Installation Methods
- Verifying Installation
- Troubleshooting
- Upgrading
- Uninstallation
The simplest way to install kubectl-mcp-tool is directly from the Python Package Index (PyPI):
pip install kubectl-mcp-tool
For a specific version:
pip install kubectl-mcp-tool==1.0.0
The package is available on PyPI: https://pypi.org/project/kubectl-mcp-tool/1.0.0/
Before installing kubectl-mcp-tool, ensure you have the following:
- Python 3.9 or higher
- pip (Python package manager)
- kubectl CLI installed and configured
- Access to a Kubernetes cluster
- (Optional) Helm v3 for Helm operations
To check your Python version:
python --version
To check if pip is installed:
pip --version
To check if kubectl is installed:
kubectl version --client
Install the latest stable version from PyPI:
pip install kubectl-mcp-tool
Install the development version directly from GitHub:
pip install git+https://github.com/rohitg00/kubectl-mcp-server.git
For a more isolated installation that doesn't affect your system Python:
# Install pipx if you don't have it
pip install pipx
pipx ensurepath
# Install kubectl-mcp-tool
pipx install kubectl-mcp-tool
If you want to modify the code or contribute to the project:
# Clone the repository
git clone https://github.com/rohitg00/kubectl-mcp-server.git
cd kubectl-mcp-server
# Install dependencies
pip install -r requirements.txt
# Install in development mode
pip install -e .
For containerized usage:
# Pull the Docker image
docker pull rohitg00/kubectl-mcp-tool:latest
# Run the container
docker run -it --rm \
-v ~/.kube:/root/.kube \
rohitg00/kubectl-mcp-tool:latest
After installation, verify that the tool is working correctly:
# Check version
kubectl-mcp --version
# Check CLI mode
kubectl-mcp --help
# Test connection to Kubernetes
kubectl-mcp get pods
-
Command not found:
- Ensure the installation directory is in your PATH
- For pipx installations, run
pipx ensurepath
and restart your terminal
-
Permission errors during installation:
- Use
pip install --user kubectl-mcp-tool
to install for the current user only - On Linux/macOS, you might need to use
sudo pip install kubectl-mcp-tool
- Use
-
Dependency conflicts:
- Create a virtual environment:
python -m venv venv && source venv/bin/activate
- Then install within the virtual environment
- Create a virtual environment:
-
Kubernetes connection issues:
- Ensure your kubeconfig is correctly set up:
kubectl config view
- Check that your cluster is accessible:
kubectl cluster-info
- Ensure your kubeconfig is correctly set up:
-
ImportError: cannot import name 'Parameter' from 'mcp.types':
- This is due to an MCP SDK version mismatch. Run the following commands to fix:
# Uninstall conflicting packages pip uninstall -y kubectl-mcp-tool fastmcp mcp mcp-python # Install the correct version pip install mcp>=1.5.0 # Reinstall kubectl-mcp-tool pip install kubectl-mcp-tool
-
AttributeError: module 'kubectl_mcp_tool.cli' has no attribute 'main':
- This is due to a CLI module path issue. Update your installation:
pip uninstall -y kubectl-mcp-tool git clone https://github.com/rohitg00/kubectl-mcp-server.git cd kubectl-mcp-server pip install -e .
- Or use our automatic install script:
bash install.sh
-
MCP Server compatibility issues:
- Make sure you're using the correct MCP configuration for your AI assistant
- For Cursor AI, use this configuration in
~/.cursor/mcp.json
:
{ "mcpServers": { "kubernetes": { "command": "python", "args": ["-m", "kubectl_mcp_tool.minimal_wrapper"], "env": { "KUBECONFIG": "/path/to/your/.kube/config", "PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin" } } } }
- Replace
/path/to/your/.kube/config
with your actual kubeconfig path (usually~/.kube/config
) - The
minimal_wrapper
module provides the most stable implementation for AI assistants
-
Server implementation issues:
- This tool uses FastMCP from MCP SDK 1.5.0+ with a minimal wrapper approach
- Key points about the implementation:
- We use the simple
@server.tool(name)
decorator format without complex parameters - The minimal wrapper has better compatibility across MCP SDK versions
- For debugging issues, run:
python -m kubectl_mcp_tool.minimal_wrapper
- We use the simple
-
Client closed or connection errors:
- If you see "client closed" errors in your AI assistant, check:
- Your kubeconfig path is correct in the configuration
- kubectl is installed and in your PATH
- You have proper permissions to access your Kubernetes cluster
- Run the installation script:
bash install.sh
which handles these issues automatically
- If you see "client closed" errors in your AI assistant, check:
If you encounter issues not covered here:
- Check the GitHub Issues for similar problems
- Join our Discord community for real-time support
- Open a new issue on GitHub with details about your problem
To upgrade to the latest version:
pip install --upgrade kubectl-mcp-tool
To upgrade to a specific version:
pip install --upgrade kubectl-mcp-tool==1.0.0
To uninstall kubectl-mcp-tool:
pip uninstall kubectl-mcp-tool
If installed with pipx:
pipx uninstall kubectl-mcp-tool