# kubectl-mcp-server

> MCP Server

The Kubectl MCP Tool is a Model Context Protocol server for Kubernetes, enabling AI assistants to interact with clusters using natural language for core operations and resource management.

## Overview

- **Category:** Developer Tools
- **Language:** Python
- **Stars:** 947
- **Forks:** 18
- **Owner:** rohitg00
- **GitHub:** https://github.com/rohitg00/kubectl-mcp-server
- **Created:** 2025-03-23T17:49:07+00:00
- **Updated:** 2025-03-28T23:36:13+00:00
- **Source:** https://model-context-protocol.com/servers/kubernetes-ai-assistant-natural-language-control

## Setup

## Setup

For detailed installation instructions, please see the [Installation Guide](./docs/INSTALLATION.md).

You can install kubectl-mcp-tool directly from PyPI:

```bash
pip install kubectl-mcp-tool
```

For a specific version:

```bash
pip install kubectl-mcp-tool==1.1.0
```

The package is available on PyPI: [https://pypi.org/project/kubectl-mcp-tool/1.1.0/](https://pypi.org/project/kubectl-mcp-tool/1.1.0/)

### Prerequisites

- Python 3.9+
- kubectl CLI installed and configured
- Access to a Kubernetes cluster
- pip (Python package manager)

### Global Installation

```bash
# 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
```

### Local Development Installation

```bash
# Clone the repository
git clone https://github.com/rohitg00/kubectl-mcp-server.git
cd kubectl-mcp-server

# Install in development mode
pip install -e .
```

### Verifying Installation

After installation, verify the tool is working correctly:

```bash
# 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.

### Claude Desktop

Add the following to your Claude Desktop configuration at `~/.config/claude/mcp.json` (Windows: `%APPDATA%\Claude\mcp.json`):

```json
{
  "mcpServers": {
    "kubernetes": {
      "command": "python",
      "args": ["-m", "kubectl_mcp_tool.minimal_wrapper"],
      "env": {
        "KUBECONFIG": "/path/to/your/.kube/config"
      }
    }
  }
}
```

### Cursor AI

Add the following to your Cursor AI settings under MCP by adding a new global MCP server:

```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"
      }
    }
  }
}
```

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`.

### Windsurf

Add the following to your Windsurf configuration at `~/.config/windsurf/mcp.json` (Windows: `%APPDATA%\WindSurf\mcp.json`):

```json
{
  "mcpServers": {
    "kubernetes": {
      "command": "python",
      "args": ["-m", "kubectl_mcp_tool.minimal_wrapper"],
      "env": {
        "KUBECONFIG": "/path/to/your/.kube/config"
      }
    }
  }
}
```

### Automatic Configuration

For automatic configuration of all supported AI assistants, run the provided installation script:

```bash
bash install.sh
```

This script will:
1. Install the required dependencies
2. Create configuration files for Claude, Cursor, and WindSurf
3. Set up the correct paths and environment variables
4. Test your Kubernetes connection

## Prerequisites

1. kubectl installed and in your PATH
2. A valid kubeconfig file
3. Access to a Kubernetes cluster
4. Helm v3 (optional, for Helm operations)

## Tools

## Available Tools

1.  Core Kubernetes Operations (Connect to a Kubernetes cluster, List and manage pods, services, deployments, and nodes, etc.)
2.  Natural Language Processing (Process natural language queries for kubectl operations, Context-aware commands with memory of previous operations, etc.)
3.  Monitoring (Cluster health monitoring, Resource utilization tracking, Pod status and health checks, etc.)
4.  Security (RBAC validation and verification, Security context auditing, Secure connections to Kubernetes API, etc.)
5.  Diagnostics (Cluster diagnostics and troubleshooting, Configuration validation, Error analysis and recovery suggestions, etc.)
6.  Advanced Features (Multiple transport protocols support (stdio, SSE), Integration with multiple AI assistants, Extensible tool framework, etc.)
