Chat with your Kubernetes Cluster using AI tools and IDEs like Claude and Cursor!
A Model Context Protocol (MCP) server for Kubernetes that enables AI assistants like Claude, Cursor, and others to interact with Kubernetes clusters through natural language.
kubectl-mcp-tool
in Action with Claude!kubectl-mcp-tool
in Action with Cursor!kubectl-mcp-tool
in Action with Windsurf!The Kubectl MCP Tool implements the Model Context Protocol (MCP), enabling AI assistants to interact with Kubernetes clusters through a standardized interface. The architecture consists of:
The tool operates in two modes:
For detailed installation instructions, please see the Installation Guide.
You can install kubectl-mcp-tool directly from PyPI:
pip install kubectl-mcp-tool
For a specific version:
pip install kubectl-mcp-tool==1.1.1
The package is available on PyPI: https://pypi.org/project/kubectl-mcp-tool/1.1.1/
# Install latest version from PyPI
pip install kubectl-mcp-tool
# Or install development version from GitHub
pip install git+https://github.com/rohitg00/kubectl-mcp-server.git
# Clone the repository
git clone https://github.com/rohitg00/kubectl-mcp-server.git
cd kubectl-mcp-server
# Install in development mode
pip install -e .
After installation, verify the tool is working correctly:
# Check CLI mode
kubectl-mcp --help
Note: This tool is designed to work as an MCP server that AI assistants connect to, not as a direct kubectl replacement. The primary command available is kubectl-mcp serve
which starts the MCP server.
The MCP Server (kubectl_mcp_tool.mcp_server
) is a robust implementation built on the FastMCP SDK that provides enhanced compatibility across different AI assistants:
Note: If you encounter any errors with the MCP Server implementation, you can fall back to using the minimal wrapper by replacing
kubectl_mcp_tool.mcp_server
withkubectl_mcp_tool.minimal_wrapper
in your configuration. The minimal wrapper provides basic capabilities with simpler implementation.
Direct Configuration
{
"mcpServers": {
"kubernetes": {
"command": "python",
"args": ["-m", "kubectl_mcp_tool.mcp_server"],
"env": {
"KUBECONFIG": "/path/to/your/.kube/config",
"PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
"MCP_LOG_FILE": "/path/to/logs/debug.log",
"MCP_DEBUG": "1"
}
}
}
}
Key Environment Variables
MCP_LOG_FILE
: Path to log file (recommended to avoid stdout pollution)MCP_DEBUG
: Set to "1" for verbose loggingMCP_TEST_MOCK_MODE
: Set to "1" to use mock data instead of real clusterKUBECONFIG
: Path to your Kubernetes config fileKUBECTL_MCP_LOG_LEVEL
: Set to "DEBUG", "INFO", "WARNING", or "ERROR"Testing the MCP Server You can test if the server is working correctly with:
python -m kubectl_mcp_tool.simple_ping
This will attempt to connect to the server and execute a ping command.
Alternatively, you can directly run the server with:
python -m kubectl_mcp_tool
Add the following to your Claude Desktop configuration at ~/.config/claude/mcp.json
(Windows: %APPDATA%\Claude\mcp.json
):
{
"mcpServers": {
"kubernetes": {
"command": "python",
"args": ["-m", "kubectl_mcp_tool.mcp_server"],
"env": {
"KUBECONFIG": "/path/to/your/.kube/config"
}
}
}
}
Add the following to your Cursor AI settings under MCP by adding a new global MCP server:
{
"mcpServers": {
"kubernetes": {
"command": "python",
"args": ["-m", "kubectl_mcp_tool.mcp_server"],
"env": {
"KUBECONFIG": "/path/to/your/.kube/config",
"PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin"
}
}
}
}
Save this configuration to ~/.cursor/mcp.json
for global settings.
Note: Replace
/path/to/your/.kube/config
with the actual path to your kubeconfig file. On most systems, this is~/.kube/config
.
Add the following to your Windsurf configuration at ~/.config/windsurf/mcp.json
(Windows: %APPDATA%\WindSurf\mcp.json
):
{
"mcpServers": {
"kubernetes": {
"command": "python",
"args": ["-m", "kubectl_mcp_tool.mcp_server"],
"env": {
"KUBECONFIG": "/path/to/your/.kube/config"
}
}
}
}
For automatic configuration of all supported AI assistants, run the provided installation script:
bash install.sh
This script will:
List all pods in the default namespace
Create a deployment named nginx-test with 3 replicas using the nginx:latest image
Get logs from the nginx-test pod
Forward local port 8080 to port 80 on the nginx-test pod
# 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 .
# Run the MCP server
python -m kubectl_mcp_tool
# Run tests
python -m python_tests.run_mcp_tests
โโโ kubectl_mcp_tool/ # Main package
โ โโโ __init__.py # Package initialization
โ โโโ __main__.py # Package entry point
โ โโโ cli.py # CLI entry point
โ โโโ mcp_server.py # MCP server implementation
โ โโโ mcp_kubectl_tool.py # Main kubectl MCP tool implementation
โ โโโ natural_language.py # Natural language processing
โ โโโ diagnostics.py # Diagnostics functionality
โ โโโ core/ # Core functionality
โ โโโ security/ # Security operations
โ โโโ monitoring/ # Monitoring functionality
โ โโโ utils/ # Utility functions
โ โโโ cli/ # CLI functionality components
โโโ python_tests/ # Test suite
โ โโโ run_mcp_tests.py # Test runner script
โ โโโ mcp_client_simulator.py # MCP client simulator for mock testing
โ โโโ test_utils.py # Test utilities
โ โโโ test_mcp_core.py # Core MCP tests
โ โโโ test_mcp_security.py # Security tests
โ โโโ test_mcp_monitoring.py # Monitoring tests
โ โโโ test_mcp_nlp.py # Natural language tests
โ โโโ test_mcp_diagnostics.py # Diagnostics tests
โ โโโ mcp_test_strategy.md # Test strategy documentation
โโโ docs/ # Documentation
โ โโโ README.md # Documentation overview
โ โโโ INSTALLATION.md # Installation guide
โ โโโ integration_guide.md # Integration guide
โ โโโ cursor/ # Cursor integration docs
โ โโโ windsurf/ # Windsurf integration docs
โ โโโ claude/ # Claude integration docs
โโโ compatible_servers/ # Compatible MCP server implementations
โ โโโ cursor/ # Cursor-compatible servers
โ โโโ windsurf/ # Windsurf-compatible servers
โ โโโ minimal/ # Minimal server implementations
โ โโโ generic/ # Generic MCP servers
โโโ requirements.txt # Python dependencies
โโโ setup.py # Package setup script
โโโ pyproject.toml # Project configuration
โโโ MANIFEST.in # Package manifest
โโโ mcp_config.json # Sample MCP configuration
โโโ run_server.py # Server runner script
โโโ LICENSE # MIT License
โโโ CHANGELOG.md # Version history
โโโ .gitignore # Git ignore file
โโโ install.sh # Installation script
โโโ publish.sh # PyPI publishing script
โโโ start_mcp_server.sh # Server startup script
The MCP Server implementation (kubectl_mcp_tool.mcp_server
) provides a comprehensive set of 26 tools that can be used by AI assistants to interact with Kubernetes clusters:
All tools return structured data with success/error information and relevant details, making it easy for AI assistants to process and understand the responses.
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.
No configuration available
This service may require manual configuration, please check the details on the left
Related projects feature coming soon
Will recommend related projects based on sub-categories