Kubernetes MCP server

Enables natural language interaction with Kubernetes clusters for resource querying and CRUD operations with configurable write permissions.
Back to servers
Setup instructions
Provider
silenceper
Release date
Apr 03, 2025
Language
Go
Stats
115 stars

MCP-K8S is a Kubernetes MCP (Model Control Protocol) server that enables interaction with Kubernetes clusters through natural language. It allows you to manage Kubernetes resources and Helm charts using plain language commands instead of memorizing complex kubectl syntax.

Installation Options

Using Pre-built Binaries

You can download the latest binary directly from the GitHub releases page:

# Download from https://github.com/silenceper/mcp-k8s/releases
# Choose the appropriate binary for your platform

Using Go Install

Install directly using Go:

go install github.com/silenceper/mcp-k8s/cmd/mcp-k8s@latest

Building from Source

Clone the repository and build the binary:

git clone https://github.com/silenceper/mcp-k8s.git
cd mcp-k8s
go build -o bin/mcp-k8s cmd/mcp-k8s/main.go

Using Docker

docker run --rm -p 8080:8080 -i -v ~/.kube/config:/root/.kube/config ghcr.io/silenceper/mcp-k8s:latest -transport=sse

Configuration and Usage

MCP-K8S supports two communication modes: stdio (default) and SSE.

Command Line Arguments

Kubernetes Resource Operations

  • -kubeconfig: Path to Kubernetes configuration file (uses default config if not specified)
  • -enable-create: Enable resource creation operations (default: false)
  • -enable-update: Enable resource update operations (default: false)
  • -enable-delete: Enable resource deletion operations (default: false)
  • -enable-list: Enable resource list operations (default: true)

Helm Operations

  • -enable-helm-release-list: Enable Helm release list operations (default: true)
  • -enable-helm-release-get: Enable Helm release get operations (default: true)
  • -enable-helm-install: Enable Helm chart installation (default: false)
  • -enable-helm-upgrade: Enable Helm chart upgrade (default: false)
  • -enable-helm-uninstall: Enable Helm chart uninstallation (default: false)
  • -enable-helm-repo-list: Enable Helm repository list operations (default: true)
  • -enable-helm-repo-add: Enable Helm repository add operations (default: false)
  • -enable-helm-repo-remove: Enable Helm repository remove operations (default: false)

Transport Configuration

  • -transport: Transport type (stdio or sse) (default: "stdio")
  • -host: Host for SSE transport (default "localhost")
  • -port: TCP port for SSE transport (default 8080)

Using Stdio Mode (Default)

For stdio mode, configure your MCP client with the following configuration:

{
    "mcpServers": {
        "mcp-k8s": {
            "command": "/path/to/mcp-k8s",
            "args": [
                "-kubeconfig", "/path/to/kubeconfig",
                "-enable-create",
                "-enable-delete",
                "-enable-update",
                "-enable-list",
                "-enable-helm-install",
                "-enable-helm-upgrade"
            ]
        }
    }
}

Using SSE Mode

Run the server with SSE transport:

./bin/mcp-k8s -kubeconfig=/path/to/kubeconfig -transport=sse -port=8080 -host=localhost -enable-create -enable-delete -enable-list -enable-update -enable-helm-install

Configure your MCP client with:

{
  "mcpServers": {
    "mcp-k8s": {
      "url": "http://localhost:8080/sse",
      "args": []
    }
  }
}

Using Docker with stdio Mode

Configure your MCP client with:

{
  "mcpServers": {
    "mcp-k8s": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "-v",
        "~/.kube/config:/root/.kube/config",
        "--rm",
        "ghcr.io/silenceper/mcp-k8s:latest"
      ]
    }
  }
}

Available Tools

Resource Type Query Tools

  • get_api_resources: Get all supported API resource types in the cluster

Resource Operation Tools

  • get_resource: Get detailed information about a specific resource
  • list_resources: List all instances of a resource type
  • create_resource: Create new resources (disabled by default)
  • update_resource: Update existing resources (disabled by default)
  • delete_resource: Delete resources (disabled by default)

Helm Operation Tools

  • list_helm_releases: List all Helm releases in the cluster
  • get_helm_release: Get detailed information about a specific Helm release
  • install_helm_chart: Install a Helm chart (disabled by default)
  • upgrade_helm_chart: Upgrade a Helm release (disabled by default)
  • uninstall_helm_chart: Uninstall a Helm release (disabled by default)
  • list_helm_repositories: List configured Helm repositories
  • add_helm_repository: Add a new Helm repository (disabled by default)
  • remove_helm_repository: Remove a Helm repository (disabled by default)

Security Considerations

By default, MCP-K8S enables only read operations for both Kubernetes resources and Helm operations. Write operations must be explicitly enabled using command-line flags.

The server also respects the RBAC permissions of the provided kubeconfig, ensuring that operations are limited to the permissions granted to that kubeconfig.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "mcp-k8s" '{"command":"/path/to/mcp-k8s","args":["-kubeconfig","/path/to/kubeconfig","-enable-create","-enable-delete","-enable-update","-enable-list","-enable-helm-install","-enable-helm-upgrade"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "mcp-k8s": {
            "command": "/path/to/mcp-k8s",
            "args": [
                "-kubeconfig",
                "/path/to/kubeconfig",
                "-enable-create",
                "-enable-delete",
                "-enable-update",
                "-enable-list",
                "-enable-helm-install",
                "-enable-helm-upgrade"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "mcp-k8s": {
            "command": "/path/to/mcp-k8s",
            "args": [
                "-kubeconfig",
                "/path/to/kubeconfig",
                "-enable-create",
                "-enable-delete",
                "-enable-update",
                "-enable-list",
                "-enable-helm-install",
                "-enable-helm-upgrade"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later