A Kubernetes MCP (Model Control Protocol) server that enables interaction with Kubernetes clusters through MCP tools. - Query supported Kubernetes resource types (built-in resources and CRDs) - Kubernetes resource operations with fine-grained control - Read operations: get resource details, list resources by type with filtering options - Write operations: create, update, and delete resources (each
Add this skill
npx mdskills install silenceper/mcp-k8sComprehensive Kubernetes and Helm MCP server with fine-grained permission control and excellent documentation
1# mcp-k8s23[](https://github.com/silenceper/mcp-k8s/blob/main/go.mod)4[](https://github.com/silenceper/mcp-k8s/blob/main/LICENSE)5[](https://github.com/silenceper/mcp-k8s/releases)6[](https://goreportcard.com/report/github.com/silenceper/mcp-k8s)7[](https://github.com/silenceper/mcp-k8s/actions/workflows/go-ci.yml)8[](https://github.com/silenceper/mcp-k8s/pulls)910A Kubernetes MCP (Model Control Protocol) server that enables interaction with Kubernetes clusters through MCP tools.1112## Features1314- Query supported Kubernetes resource types (built-in resources and CRDs)15- Kubernetes resource operations with fine-grained control16 - Read operations: get resource details, list resources by type with filtering options17 - Write operations: create, update, and delete resources (each can be independently enabled/disabled)18 - Support for all Kubernetes resource types, including custom resources19- Connects to Kubernetes cluster using kubeconfig20- Helm support with fine-grained control21 - Helm releases management (list, get, install, upgrade, uninstall)22 - Helm repositories management (list, add, remove)23 - Each operation can be independently enabled/disabled2425## Preview26> Interaction through cursor27282930## Use Cases3132### 1. Kubernetes Resource Management via LLM3334- **Interactive Resource Management**: Manage Kubernetes resources through natural language interaction with LLM, eliminating the need to memorize complex kubectl commands35- **Batch Operations**: Describe complex batch operation requirements in natural language, letting LLM translate them into specific resource operations36- **Resource Status Queries**: Query cluster resource status using natural language and receive easy-to-understand responses3738### 2. Automated Operations Scenarios3940- **Intelligent Operations Assistant**: Serve as an intelligent assistant for operators in daily cluster management tasks41- **Problem Diagnosis**: Assist in cluster problem diagnosis through natural language problem descriptions42- **Configuration Review**: Leverage LLM's understanding capabilities to help review and optimize Kubernetes resource configurations4344### 3. Development and Testing Support4546- **Quick Prototype Validation**: Developers can quickly create and validate resource configurations through natural language47- **Environment Management**: Simplify test environment resource management, quickly create, modify, and clean up test resources48- **Configuration Generation**: Automatically generate resource configurations that follow best practices based on requirement descriptions4950### 4. Education and Training Scenarios5152- **Interactive Learning**: Newcomers can learn Kubernetes concepts and operations through natural language interaction53- **Best Practice Guidance**: LLM provides best practice suggestions during resource operations54- **Error Explanation**: Provide easy-to-understand error explanations and correction suggestions when operations fail5556## Architecture5758### 1. Project Overview5960An stdio-based MCP server that connects to Kubernetes clusters and provides the following capabilities:61- Query Kubernetes resource types (including built-in resources and CRDs)62- CRUD operations on Kubernetes resources (with configurable write operations)63- Helm operations for release and repository management6465### 2. Technical Stack6667- Go68- [mcp-go](https://github.com/mark3labs/mcp-go) SDK69- Kubernetes client-go library70- Helm v3 client library71- Stdio for communication7273### 3. Core Components74751. **MCP Server**: Uses mcp-go's `mcp-k8s` package to create an stdio-based MCP server762. **K8s Client**: Uses client-go to connect to Kubernetes clusters773. **Helm Client**: Uses Helm v3 library for Helm operations784. **Tool Implementations**: Implements various MCP tools for different Kubernetes operations7980### 4. Available Tools8182#### Resource Type Query Tools83- `get_api_resources`: Get all supported API resource types in the cluster8485#### Resource Operation Tools86- `get_resource`: Get detailed information about a specific resource87- `list_resources`: List all instances of a resource type88- `create_resource`: Create new resources (can be disabled)89- `update_resource`: Update existing resources (can be disabled)90- `delete_resource`: Delete resources (can be disabled)9192#### Helm Operation Tools93- `list_helm_releases`: List all Helm releases in the cluster94- `get_helm_release`: Get detailed information about a specific Helm release95- `install_helm_chart`: Install a Helm chart (can be disabled)96- `upgrade_helm_chart`: Upgrade a Helm release (can be disabled)97- `uninstall_helm_chart`: Uninstall a Helm release (can be disabled)98- `list_helm_repositories`: List configured Helm repositories99- `add_helm_repository`: Add a new Helm repository (can be disabled)100- `remove_helm_repository`: Remove a Helm repository (can be disabled)101102## Usage103104mcp-k8s supports three communication modes:105106### 1. Stdio Mode (Default)107108In stdio mode, mcp-k8s communicates with the client through standard input/output streams. This is the default mode and is suitable for most use cases.109110```bash111# Run in stdio mode (default)112{113 "mcpServers":114 {115 "mcp-k8s":116 {117 "command": "/path/to/mcp-k8s",118 "args":119 [120 "--kubeconfig",121 "/path/to/kubeconfig",122 "--enable-create",123 "--enable-delete",124 "--enable-update",125 "--enable-list",126 "--enable-helm-install",127 "--enable-helm-upgrade"128 ]129 }130 }131}132```133134### 2. SSE Mode135136In SSE (Server-Sent Events) mode, mcp-k8s exposes an HTTP endpoint to mcp client.137You can deploy the service on a remote server (but you need to pay attention to security)138139```bash140# Run in SSE mode141./bin/mcp-k8s --kubeconfig=/path/to/kubeconfig --transport=sse --port=8080 --host=localhost --enable-create --enable-delete --enable-list --enable-update --enable-helm-install142# This command will open all operations143```144145mcp config146```json147{148 "mcpServers": {149 "mcp-k8s": {150 "url": "http://localhost:8080/sse",151 "args": []152 }153 }154}155```156157SSE mode configuration:158- `--transport`: Set to "sse" to enable SSE mode159- `--port`: HTTP server port (default: 8080)160- `--host`: HTTP server host (default: "localhost")161162### 3. Streamable HTTP Mode163164In Streamable HTTP mode, mcp-k8s exposes an HTTP endpoint that supports both direct HTTP responses and SSE streams. This mode provides better flexibility and supports streaming output.165166```bash167# Run in Streamable HTTP mode168./bin/mcp-k8s --kubeconfig=/path/to/kubeconfig --transport=streamable-http --port=8080 --host=localhost --endpoint-path=/mcp --enable-create --enable-delete --enable-list --enable-update --enable-helm-install169```170171mcp config172```json173{174 "mcpServers": {175 "mcp-k8s": {176 "url": "http://localhost:8080/mcp",177 "args": []178 }179 }180}181```182183Streamable HTTP mode configuration:184- `--transport`: Set to "streamable-http" to enable Streamable HTTP mode185- `--port`: HTTP server port (default: 8080)186- `--host`: HTTP server host (default: "localhost")187- `--endpoint-path`: Endpoint path for the MCP server (default: "/mcp")188189### 4. Docker environment190#### SSE Mode1911921. Complete Example193Assuming your image name is mcp-k8s and you need to map ports and set environment parameters, you can run:194```bash195docker run --rm -p 8080:8080 -i -v ~/.kube/config:/root/.kube/config ghcr.io/silenceper/mcp-k8s:latest --transport=sse196```197198#### Streamable HTTP Mode199200```bash201docker run --rm -p 8080:8080 -i -v ~/.kube/config:/root/.kube/config ghcr.io/silenceper/mcp-k8s:latest --transport=streamable-http --endpoint-path=/mcp202```203#### stdio Mode204205```json206{207 "mcpServers": {208 "mcp-k8s": {209 "command": "docker",210 "args": [211 "run",212 "-i",213 "-v",214 "~/.kube/config:/root/.kube/config",215 "--rm",216 "ghcr.io/silenceper/mcp-k8s:latest"217 ]218 }219 }220}221```222223224## Getting Started225226### Direct Usage227You can directly download the binary for your platform from the [releases page](https://github.com/silenceper/mcp-k8s/releases) and use it immediately.228229### Go Install230231```bash232go install github.com/silenceper/mcp-k8s/cmd/mcp-k8s@latest233```234235### Build236237#### Using Makefile (Recommended)238239The Makefile automatically injects version information from the VERSION file:240241```bash242git clone https://github.com/silenceper/mcp-k8s.git243cd mcp-k8s244make build245```246247This will build with version information injected via ldflags.248249#### Direct Build250251```bash252git clone https://github.com/silenceper/mcp-k8s.git253cd mcp-k8s254go build -o bin/mcp-k8s cmd/mcp-k8s/main.go255```256257Note: Direct build will show version as "dev" unless you specify ldflags manually.258259### Command Line Arguments260261You can use `mcp-k8s --help` to see all available options, or `mcp-k8s --version` to check the version.262263#### Kubernetes Resource Operations264- `--kubeconfig`: Path to Kubernetes configuration file (uses default config if not specified)265- `--enable-create`: Enable resource creation operations (default: false)266- `--enable-update`: Enable resource update operations (default: false)267- `--enable-delete`: Enable resource deletion operations (default: false)268- `--enable-list`: Enable resource list operations (default: true)269270#### Helm Operations271- `--enable-helm-release-list`: Enable Helm release list operations (default: true)272- `--enable-helm-release-get`: Enable Helm release get operations (default: true)273- `--enable-helm-install`: Enable Helm chart installation (default: false)274- `--enable-helm-upgrade`: Enable Helm chart upgrade (default: false)275- `--enable-helm-uninstall`: Enable Helm chart uninstallation (default: false)276- `--enable-helm-repo-list`: Enable Helm repository list operations (default: true)277- `--enable-helm-repo-add`: Enable Helm repository add operations (default: false)278- `--enable-helm-repo-remove`: Enable Helm repository remove operations (default: false)279280#### Transport Configuration281- `--transport`: Transport type (stdio, sse, or streamable-http) (default: "stdio")282- `--host`: Host for HTTP transport (SSE or Streamable HTTP) (default: "localhost")283- `--port`: TCP port for HTTP transport (SSE or Streamable HTTP) (default: 8080)284- `--endpoint-path`: Endpoint path for Streamable HTTP transport (default: "/mcp")285286#### Version Information287- `--version`: Display version information including version, commit hash, and build date288- `--help` or `-h`: Display help information289290### Testing Streamable HTTP291292To test if Streamable HTTP mode is working correctly, you can use the provided test script:293294```bash295# Start the server in one terminal296./bin/mcp-k8s --transport=streamable-http --port=8080 --enable-list297298# In another terminal, run the test script299./test_streamable_http.sh300```301302For detailed testing instructions, see [TEST_STREAMABLE_HTTP.md](./TEST_STREAMABLE_HTTP.md).303304### Integration with MCP Clients305306mcp-k8s is an stdio-based MCP server that can be integrated with any MCP-compatible LLM client. Refer to your MCP client's documentation for integration instructions.307308## Security Considerations309310- Write operations are strictly controlled through independent configuration switches311- Uses RBAC to ensure K8s client has only necessary permissions312- Validates all user inputs to prevent injection attacks313- Helm operations follow the same security principles with read operations enabled by default and write operations disabled by default314315## Follow WeChat Official Account316317
Full transparency — inspect the skill content before installing.