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.
Empower your AI assistants with seamless Kubernetes interaction using the Model Context Protocol.
The Kubectl MCP Tool is a powerful enabler, designed to facilitate interaction between Large Language Model (LLM) applications and Kubernetes clusters. By implementing the Model Context Protocol (MCP), this tool allows AI assistants like Claude, Cursor, and others to manage and interact with your Kubernetes infrastructure using natural language commands. This significantly lowers the barrier to entry for Kubernetes management, making it accessible to a wider range of users and use cases.
This tool provides a comprehensive suite of features, enabling AI assistants to perform a wide range of Kubernetes operations:
kubectl explain
functionality and provides access to Kubernetes API resource definitions.kubectl
commands.kubectl
commands based on user intent.kubectl
execution when specialized tools are unavailable.kubectl top
.The Kubectl MCP Tool is built upon a robust architecture that leverages the Model Context Protocol (MCP) to facilitate seamless communication between AI assistants and Kubernetes clusters.
The core of the architecture revolves around the Model Context Protocol (MCP), which provides a standardized interface for AI assistants to interact with external tools and data sources. The Kubectl MCP Tool implements the MCP specification, enabling AI assistants to leverage its capabilities for Kubernetes management.
The key components of the architecture are:
The following diagram illustrates the request flow within the Kubectl MCP Tool:
The tool operates in two distinct modes:
For detailed installation instructions, please refer to the Installation Guide.
The recommended installation method is using pip
:
pip install kubectl-mcp-tool
To install a specific version:
pip install kubectl-mcp-tool==1.1.0
The package is also available on PyPI: https://pypi.org/project/kubectl-mcp-tool/1.1.0/
Before installing the Kubectl MCP Tool, ensure that you have the following prerequisites:
kubectl
command-line tool must be installed and configured to access your Kubernetes cluster.pip
is required.To install the latest version from PyPI:
pip install kubectl-mcp-tool
Alternatively, to install the development version directly from GitHub:
pip install git+https://github.com/rohitg00/kubectl-mcp-server.git
For local development, follow these steps:
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 that the tool is working correctly by running:
kubectl-mcp --help
Note: This tool is primarily designed to function as an MCP server for AI assistants. The main command is kubectl-mcp serve
, which starts the MCP server.
The Kubectl MCP Tool seamlessly integrates with popular AI assistants, enabling natural language interaction with your Kubernetes cluster.
To configure the tool to work with your AI assistant, you need to provide the path to your kubeconfig
file. This file contains the necessary credentials to access your Kubernetes cluster.
Add the following configuration to ~/.config/claude/mcp.json
(or %APPDATA%\Claude\mcp.json
on Windows):
{ "mcpServers": { "kubernetes": { "command": "python", "args": ["-m", "kubectl_mcp_tool.minimal_wrapper"], "env": { "KUBECONFIG": "/path/to/your/.kube/config" } } } }
Add a new global MCP server in your Cursor AI settings with the following configuration:
{ "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" } } } }
Save this configuration to ~/.cursor/mcp.json
for global settings.
Add the following configuration to ~/.config/windsurf/mcp.json
(or %APPDATA%\WindSurf\mcp.json
on Windows):
{ "mcpServers": { "kubernetes": { "command": "python", "args": ["-m", "kubectl_mcp_tool.minimal_wrapper"], "env": { "KUBECONFIG": "/path/to/your/.kube/config" } } } }
Important: Replace /path/to/your/.kube/config
with the actual path to your kubeconfig
file. The default location is typically ~/.kube/config
.
For a streamlined setup, use the provided installation script:
bash install.sh
This script automates the following steps:
Here are some examples of how you can use the Kubectl MCP Tool with your AI assistant:
List Pods:
List all pods in the default namespace
Deploy an Application:
Create a deployment named nginx-test with 3 replicas using the nginx:latest image
Check Pod Logs:
Get logs from the nginx-test pod
Port Forwarding:
Forward local port 8080 to port 80 on the nginx-test pod
We welcome contributions to the Kubectl MCP Tool! If you're interested in contributing, follow these steps:
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 tests:
python -m python_tests.test_all_features
The project structure is organized as follows:
├── kubectl_mcp_tool/ # Main package
│ ├── __init__.py # Package initialization
│ ├── 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
├── 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
We encourage contributions to the Kubectl MCP Tool. To contribute:
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.
📇 A gateway demo for MCP SSE Server.
🐍 ☁️ A lightweight mcp server that tells you exactly what time is it.
#️⃣ 🏠 A C# SDK for building MCP servers on .NET 9 with NativeAOT compatibility ⚡ 🔌
☕ Java SDK for building MCP servers using Quarkus.