Kubernetes MCP server

Control and monitor K8s clusters for management and debugging.
Back to servers
Setup instructions
Provider
strowk
Release date
Dec 01, 2024
Language
TypeScript
Package
Stats
13.7K downloads
344 stars

MCP K8S Go is a Golang-based Model Context Protocol (MCP) server that connects to Kubernetes, allowing AI models like Claude to interact with your Kubernetes clusters. It provides a convenient interface for accessing and managing Kubernetes resources through MCP-compatible clients.

Installation Options

Using Smithery (Recommended for Claude Desktop)

The easiest way to install MCP K8S Go for Claude Desktop:

npx -y @smithery/cli install @strowk/mcp-k8s --client claude

Using mcp-get (Alternative Automatic Setup)

Another method for automatic installation with Claude Desktop:

npx @michaellatman/mcp-get@latest install @strowk/mcp-k8s

Using Pre-built NPM Package

If you have Node.js installed:

npm install -g @strowk/mcp-k8s

Then add this configuration to your claude_desktop_config.json file:

{
  "mcpServers": {
    "mcp_k8s": {
      "command": "mcp-k8s",
      "args": []
    }
  }
}

Alternatively, you can use it with npx:

{
  "mcpServers": {
    "mcp_k8s": {
      "command": "npx",
      "args": [
        "@strowk/mcp-k8s"
      ]
    }
  }
}

Using Pre-built Binaries from GitHub

  1. Download the latest release for your platform from GitHub releases
  2. Unpack the archive containing the mcp-k8s-go binary
  3. Add the binary to your PATH
  4. Configure Claude Desktop by adding to claude_desktop_config.json:
{
  "mcpServers": {
    "mcp_k8s": {
      "command": "mcp-k8s-go",
      "args": []
    }
  }
}

Building from Source

If you have Golang installed:

go get github.com/strowk/mcp-k8s-go
go install github.com/strowk/mcp-k8s-go

Then add to claude_desktop_config.json:

{
  "mcpServers": {
    "mcp_k8s_go": {
      "command": "mcp-k8s-go",
      "args": []
    }
  }
}

Using Docker

For Docker users:

docker run -i -v ~/.kube/config:/home/nonroot/.kube/config --rm mcpk8s/server:latest

Windows users might need to replace ~/.kube/config with //c/Users/<username>/.kube/config in Git Bash.

Claude Desktop configuration:

{
  "mcpServers": {
    "mcp_k8s_go": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "-v",
        "~/.kube/config:/home/nonroot/.kube/config",
        "--rm",
        "mcpk8s/server:latest"
      ]
    }
  }
}

Configuration and Usage

Environment Variables

  • KUBECONFIG: Path to your Kubernetes configuration file (defaults to ~/.kube/config)

Command-line Options

  • --allowed-contexts=<ctx1,ctx2,...>: Limit access to specific Kubernetes contexts
  • --readonly: Disable write operations to the cluster
  • --help: Display help information
  • --version: Display version information

Example configuration with options:

{
    "mcpServers": {
        "mcp_k8s": {
            "command": "mcp-k8s",
            "args": [
                "--allowed-contexts=dev,prod",
                "--readonly"
            ]
        }
    }
}

Features

MCP K8S Go provides the following capabilities:

  • List Kubernetes contexts
  • List Kubernetes namespaces
  • List, get, create and modify Kubernetes resources
  • List Kubernetes nodes
  • List Kubernetes pods
  • Get Kubernetes events
  • Get Kubernetes pod logs
  • Run commands in Kubernetes pods

Using with Inspector

To use the latest published version with Inspector:

npx @modelcontextprotocol/inspector npx @strowk/mcp-k8s

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":"npx","args":["@strowk/mcp-k8s"]}'

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": "npx",
            "args": [
                "@strowk/mcp-k8s"
            ]
        }
    }
}

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": "npx",
            "args": [
                "@strowk/mcp-k8s"
            ]
        }
    }
}

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