mcp-k8s

mcp-k8s

A Kubernetes MCP server enabling resource management via Model Control Protocol.

129
Stars
25
Forks
129
Watchers
1
Issues
mcp-k8s is a Kubernetes server that implements the Model Control Protocol (MCP), allowing users to interact with Kubernetes clusters through MCP-compatible tools. It supports querying and managing all Kubernetes resources, including custom resources, with fine-grained control over read and write operations. The server utilizes stdio communication and integrates with both Kubernetes and Helm, facilitating resource and Helm release management. It is designed to support natural language interactions with large language models for managing, diagnosing, and learning Kubernetes operations.

Key Features

Supports querying both built-in and custom Kubernetes resources (CRDs)
Fine-grained control over read and write resource operations
Enable or disable create, update, and delete operations individually
Connects using user-provided kubeconfig
Comprehensive Helm release and repository management
Each Helm operation can be independently enabled or disabled
Utilizes stdio for communication with MCP clients
Integrates with mcp-go SDK for protocol support
Secures access to sensitive cluster operations
Designed for compatibility with natural language model tools

Use Cases

Managing Kubernetes resources through natural language interactions with LLMs
Executing batch operations on clusters by describing requirements in plain language
Querying cluster resource status and health checks in conversational format
Serving as an intelligent operations assistant for troubleshooting and routine tasks
Automating configuration review and optimization with LLM recommendations
Accelerating validation and prototyping of resource configurations
Simplifying creation, modification, and cleanup of test environments
Auto-generating Kubernetes configurations based on high-level requirements
Supporting interactive education and training scenarios for Kubernetes concepts
Providing best practice suggestions and error explanations during resource management

README

mcp-k8s

Go Version License Latest Release Go Report Card Go CI PRs Welcome

A Kubernetes MCP (Model Control Protocol) server that enables interaction with Kubernetes clusters through MCP tools.

Features

  • 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 can be independently enabled/disabled)
    • Support for all Kubernetes resource types, including custom resources
  • Connects to Kubernetes cluster using kubeconfig
  • Helm support with fine-grained control
    • Helm releases management (list, get, install, upgrade, uninstall)
    • Helm repositories management (list, add, remove)
    • Each operation can be independently enabled/disabled

Preview

Interaction through cursor

Use Cases

1. Kubernetes Resource Management via LLM

  • Interactive Resource Management: Manage Kubernetes resources through natural language interaction with LLM, eliminating the need to memorize complex kubectl commands
  • Batch Operations: Describe complex batch operation requirements in natural language, letting LLM translate them into specific resource operations
  • Resource Status Queries: Query cluster resource status using natural language and receive easy-to-understand responses

2. Automated Operations Scenarios

  • Intelligent Operations Assistant: Serve as an intelligent assistant for operators in daily cluster management tasks
  • Problem Diagnosis: Assist in cluster problem diagnosis through natural language problem descriptions
  • Configuration Review: Leverage LLM's understanding capabilities to help review and optimize Kubernetes resource configurations

3. Development and Testing Support

  • Quick Prototype Validation: Developers can quickly create and validate resource configurations through natural language
  • Environment Management: Simplify test environment resource management, quickly create, modify, and clean up test resources
  • Configuration Generation: Automatically generate resource configurations that follow best practices based on requirement descriptions

4. Education and Training Scenarios

  • Interactive Learning: Newcomers can learn Kubernetes concepts and operations through natural language interaction
  • Best Practice Guidance: LLM provides best practice suggestions during resource operations
  • Error Explanation: Provide easy-to-understand error explanations and correction suggestions when operations fail

Architecture

1. Project Overview

An stdio-based MCP server that connects to Kubernetes clusters and provides the following capabilities:

  • Query Kubernetes resource types (including built-in resources and CRDs)
  • CRUD operations on Kubernetes resources (with configurable write operations)
  • Helm operations for release and repository management

2. Technical Stack

  • Go
  • mcp-go SDK
  • Kubernetes client-go library
  • Helm v3 client library
  • Stdio for communication

3. Core Components

  1. MCP Server: Uses mcp-go's mcp-k8s package to create an stdio-based MCP server
  2. K8s Client: Uses client-go to connect to Kubernetes clusters
  3. Helm Client: Uses Helm v3 library for Helm operations
  4. Tool Implementations: Implements various MCP tools for different Kubernetes operations

4. 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 (can be disabled)
  • update_resource: Update existing resources (can be disabled)
  • delete_resource: Delete resources (can be disabled)

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 (can be disabled)
  • upgrade_helm_chart: Upgrade a Helm release (can be disabled)
  • uninstall_helm_chart: Uninstall a Helm release (can be disabled)
  • list_helm_repositories: List configured Helm repositories
  • add_helm_repository: Add a new Helm repository (can be disabled)
  • remove_helm_repository: Remove a Helm repository (can be disabled)

Usage

mcp-k8s supports two communication modes:

1. Stdio Mode (Default)

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

bash
# Run in stdio mode (default)
{
    "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"
            ]
        }
    }
}

2. SSE Mode

In SSE (Server-Sent Events) mode, mcp-k8s exposes an HTTP endpoint to mcp client. You can deploy the service on a remote server (but you need to pay attention to security)

bash
# Run in SSE mode
./bin/mcp-k8s -kubeconfig=/path/to/kubeconfig -transport=sse -port=8080 -host=localhost -enable-create -enable-delete -enable-list -enable-update -enable-helm-install
# This command will open all operations

mcp config

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

SSE mode configuration:

  • -transport: Set to "sse" to enable SSE mode
  • -port: HTTP server port (default: 8080)
  • --host: HTTP server host (default: "localhost")

3. Docker environment

SSE Mode

  1. Complete Example Assuming your image name is mcp-k8s and you need to map ports and set environment parameters, you can run:
bash
docker run --rm -p 8080:8080 -i -v ~/.kube/config:/root/.kube/config ghcr.io/silenceper/mcp-k8s:latest -transport=sse

stdio Mode

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

Getting Started

Direct Usage

You can directly download the binary for your platform from the releases page and use it immediately.

Go Install

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

Build

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

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)

Integration with MCP Clients

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

Security Considerations

  • Write operations are strictly controlled through independent configuration switches
  • Uses RBAC to ensure K8s client has only necessary permissions
  • Validates all user inputs to prevent injection attacks
  • Helm operations follow the same security principles with read operations enabled by default and write operations disabled by default

Follow WeChat Official Account

AI技术小林

Star History

Star History Chart

Repository Owner

silenceper
silenceper

User

Repository Details

Language Go
Default Branch main
Size 798 KB
Contributors 5
License Apache License 2.0
MCP Verified Nov 11, 2025

Programming Languages

Go
95.63%
Makefile
3.13%
Dockerfile
1.24%

Tags

Topics

debug kubernetes mcp mcp-server

Join Our Newsletter

Stay updated with the latest AI tools, news, and offers by subscribing to our weekly newsletter.

We respect your privacy. Unsubscribe at any time.

Related MCPs

Discover similar Model Context Protocol servers

  • MKP

    MKP

    A Model Context Protocol server enabling LLM-powered applications to interact with Kubernetes clusters.

    MKP is a Model Context Protocol (MCP) server designed for Kubernetes environments, allowing large language model (LLM) powered applications to list, retrieve, and apply Kubernetes resources through a standardized protocol interface. Built natively in Go, it utilizes Kubernetes API machinery to provide direct, type-safe, and reliable operations without dependencies on CLI tools. MKP offers a minimalist, pluggable design enabling universal resource support, including custom resource definitions, and includes built-in rate limiting for production readiness.

    • 54
    • MCP
    • StacklokLabs/mkp
  • MCP K8S Go

    MCP K8S Go

    Golang-based MCP server that enables AI-driven interactions with Kubernetes clusters.

    MCP K8S Go provides a server implementation of the Model Context Protocol for managing and interacting with Kubernetes clusters. It offers functionality to list, retrieve, create, and modify Kubernetes resources such as contexts, namespaces, pods, and nodes using standardized context-aware approaches. Designed for integration with AI assistants like Claude Desktop, it enables prompting and tool execution to manage cluster state, monitor events, fetch pod logs, and run in-pod commands. The solution supports deployment via various installation methods including Docker, Node.js, and Go binaries.

    • 356
    • MCP
    • strowk/mcp-k8s-go
  • mcp-k8s-eye

    mcp-k8s-eye

    Kubernetes management and diagnostics tool with MCP protocol support.

    mcp-k8s-eye enables users to manage and analyze Kubernetes clusters using standardized Model Context Protocol (MCP) interfaces. It offers comprehensive resource operations, diagnostics, and resource usage monitoring through both stdio and SSE transports. Supporting generic and custom resource management along with advanced diagnostic tooling, it is geared for integration with AI clients and other MCP consumers.

    • 26
    • MCP
    • wenhuwang/mcp-k8s-eye
  • MCP Server Kubernetes

    MCP Server Kubernetes

    Connect and manage Kubernetes clusters via Model Context Protocol servers.

    MCP Server Kubernetes enables seamless connection and management of Kubernetes clusters through the Model Context Protocol. It supports loading kubeconfig from multiple sources, integrates easily with Claude Code, Claude Desktop, and VS Code, and offers flexible authentication mechanisms. Users can control clusters using standard command-line tools and extension integrations for multiple environments.

    • 1,181
    • MCP
    • Flux159/mcp-server-kubernetes
  • K8M

    K8M

    AI-driven lightweight Kubernetes dashboard with integrated MCP and multi-cluster management.

    K8M is an AI-enabled mini Kubernetes dashboard built with a focus on simplifying cluster management and enhancing user experience. Utilizing the Model Context Protocol (MCP), K8M offers visual management for MCP, allowing AI models to interact with Kubernetes resources and tools easily, supporting over 49 built-in MCP tools. It enables powerful multi-cluster management, integrates advanced AI capabilities such as chat-driven resource explanation and diagnostics, and supports custom large model integration including private deployments and models like Ollama.

    • 702
    • MCP
    • weibaohui/k8m
  • Inspektor Gadget MCP Server

    Inspektor Gadget MCP Server

    AI-powered Kubernetes troubleshooting via Model Context Protocol.

    Inspektor Gadget MCP Server provides an AI-powered debugging and inspection interface for Kubernetes clusters. Leveraging the Model Context Protocol, it enables intelligent output summarization, one-click deployment of Inspektor Gadget, and automated discovery of debugging tools from Artifact Hub. The server integrates seamlessly with VS Code for interactive AI commands, simplifying Kubernetes troubleshooting and monitoring workflows.

    • 16
    • MCP
    • inspektor-gadget/ig-mcp-server
  • Didn't find tool you were looking for?

    Be as detailed as possible for better results