ko

kom

Provides MCP multi-cluster Kubernetes management and operations. It can be integrated as an SDK into your own project and includes nearly 50 built-in tools covering common DevOps and development scenarios. Supports both standard and CRD resources.

Publisherkom
Submitted date4/13/2025

Kom: The Kubernetes Swiss Army Knife - Simplifying Cluster Operations with Go

kom is a powerful Go library designed to streamline Kubernetes operations, acting as a comprehensive SDK-level wrapper around kubectl and client-go. It empowers developers to effortlessly manage Kubernetes resources, including creation, updates, deletion, and retrieval, while seamlessly handling Custom Resource Definitions (CRDs). With kom, you can easily perform CRUD operations, access logs, manipulate files within pods, and even leverage SQL queries to manage your Kubernetes resources.

Key Features

  • Effortless Resource Management: kom provides a rich set of functions for creating, updating, deleting, and retrieving both built-in and CRD Kubernetes resources.
  • Multi-Cluster Support: Manage multiple Kubernetes clusters with ease using the RegisterCluster function.
  • Model Context Protocol (MCP) Integration: Seamlessly integrate with MCP for multi-cluster management, supporting both stdio and SSE modes. Benefit from 48 built-in tools and over a hundred combined operations, enabling private deployments and multi-user sharing.
  • Cross-Namespace Operations: Query resources across multiple namespaces using kom.Namespace("default","kube-system").List(&items).
  • Chained Functionality: kom's intuitive chained function calls simplify resource manipulation.
  • CRD Support: Define and manage custom resources effortlessly with kom's CRD support.
  • Extensible Callbacks: Easily extend business logic without tight coupling to Kubernetes operations through customizable callbacks.
  • In-Pod File Management: Upload, download, and delete files within pods with ease.
  • High-Frequency Operation Wrappers: Leverage pre-built functions for common operations like deployment restarts, scaling, and start/stop actions.
  • SQL-Based Resource Queries: Use SQL to query Kubernetes resources, e.g., select * from pod where metadata.namespace='kube-system' or metadata.namespace='default' order by metadata.creationTimestamp desc.
  • Query Caching: Enhance performance in high-frequency, batch query scenarios by setting cache expiration times. List filtering remains unaffected by caching.

Example Application: k8m

k8m is a lightweight Kubernetes management tool built on kom and amis. It's a single-file application that supports multiple platforms.

  1. Download: Get the latest version from https://github.com/weibaohui/k8m.
  2. Run: Start the application with ./k8m and access it at http://127.0.0.1:3618.

Installation

import ( "github.com/weibaohui/kom" "github.com/weibaohui/kom/callbacks" ) func main() { // Register callbacks (must be done first) callbacks.RegisterInit() // Register clusters defaultKubeConfig := os.Getenv("KUBECONFIG") if defaultKubeConfig == "" { defaultKubeConfig = filepath.Join(homedir.HomeDir(), ".kube", "config") } _, _ = kom.Clusters().RegisterInCluster() _, _ = kom.Clusters().RegisterByPathWithID(defaultKubeConfig, "default") kom.Clusters().Show() // Your application logic here }

Usage Examples

0. Multi-Cluster Kubernetes MCP Support

Supports both stdio and SSE modes, along with multiple tools for querying, listing, deleting, describing resources, and reading pod logs.

1. Integrate into your code

// Start the MCP server with a single line of code mcp.RunMCPServer("kom mcp server", "0.0.1", 9096)

2. Build

# Build from source go build main.go # Compile to 'kom'

3. Run

After building, you can use it in either stdio or SSE mode. Kubernetes management defaults to using the KUBECONFIG environment variable.

# Set the KUBECONFIG environment variable export KUBECONFIG=/Users/xxx/.kube/config
# Run ./kom # MCP Server access address http://IP:9096/sse

The compiled binary can be used in stdio mode. The http://IP:9096/sse address can be used in SSE mode.

4. Integrate into MCP Tools

Supports both stdio and SSE integration, suitable for MCP tools like Cursor, Claude Desktop (stdio only), Windsurf, and others. You can also add it through the UI of these tools.

{ "mcpServers": { "kom": { "type": "sse", "url": "http://IP:9096/sse" } } }
{ "mcpServers": { "k8m": { "command": "path/to/kom", "args": [] } } }

MCP Tool List (49 Tools)

| Category | Method | Description

Visit More

View All