About kubernetes-mcp
kubernetes-mcp is a MCP server written in Go that exposes Kubernetes operations as MCP tools. It supports stdio, sse and streamable transports and works with a local kubeconfig or in-cluster service account configuration.
Key features
- 01Generic resource CRUD tools per API group prefix
- 02Supports stdio, SSE and StreamableHTTP transports
- 03Works with kubeconfig or in-cluster configuration
- 04Pod log analysis, event and manifest utilities
- 05Troubleshooting prompts and metrics tools
Use cases
- 01Querying and managing cluster resources from MCP clients
- 02Analyzing pod logs and troubleshooting pods, nodes or networking
- 03Running as a remote MCP service inside a Kubernetes cluster
MCP support
This is an MCP server that exposes Kubernetes resource operations, tools, prompts and metrics to MCP clients.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN mcp/githubGITHUB_PERSONAL_ACCESS_TOKENSecretLocal servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEKubernetes MCP
English | 中文
A Kubernetes-focused Model Context Protocol (MCP) server built in Go.
It exposes Kubernetes operations as MCP tools and supports stdio, sse, and streamable transports.
Why This Project
- Unified MCP interface for Kubernetes operations
- Works with both local
kubeconfigand in-cluster configuration - Multiple transports for different integration modes
- Generic resource CRUD + utility tools + prompts + metrics
slog-based logging with configurable level/format
Requirements
- Go
1.24+ - Access to a Kubernetes cluster
- via
--kubeconfig, or - via in-cluster service account
- via
Quick Start
Build
git clone https://github.com/HSn0918/kubernetes-mcp.git
cd kubernetes-mcp
go build -o kubernetes-mcp ./cmd/kubernetes-mcp
Run (stdio)
./kubernetes-mcp server transport stdio --kubeconfig ~/.kube/config
Run (SSE)
./kubernetes-mcp server transport sse \
--port 8080 \
--health-port 8081 \
--allow-origins "*" \
--base-url "http://localhost:8080" \
--kubeconfig ~/.kube/config
Run (StreamableHTTP)
./kubernetes-mcp server transport streamable \
--port 8080 \
--health-port 8081 \
--allow-origins "*" \
--kubeconfig ~/.kube/config
CLI Structure
kubernetes-mcp
├── server
│ └── transport
│ ├── stdio
│ ├── sse
│ └── streamable
└── version
Configuration Flags
Global flags:
--log-level(debug|info|warn|error, defaultinfo)--log-format(console|json, defaultconsole)--kubeconfig(optional)
Network transport flags (sse, streamable):
--port(default8080)--health-port(default8081)--allow-origins(default*)
SSE-only flags:
--base-url(defaulthttp://localhost:<port>)
Transport Endpoints
- StreamableHTTP MCP endpoint:
POST /mcp - Health endpoints (SSE/Streamable only):
GET /healthzGET /readyz
Tooling Overview
1. Generic Resource Operations
For each API group prefix, the server exposes:
LIST_<PREFIX>_RESOURCESGET_<PREFIX>_RESOURCEDESCRIBE_<PREFIX>_RESOURCECREATE_<PREFIX>_RESOURCEUPDATE_<PREFIX>_RESOURCEDELETE_<PREFIX>_RESOURCE
Registered prefixes:
K8S
2. Core/Cluster Utilities
LIST_NAMESPACESLIST_NODESGET_POD_LOGSANALYZE_POD_LOGS
3. Utility Tools
GET_CURRENT_TIMEGET_CLUSTER_INFOGET_API_RESOURCESSEARCH_RESOURCESEXPLAIN_RESOURCEAPPLY_MANIFESTVALIDATE_MANIFESTDIFF_MANIFESTGET_EVENTS
4. Prompt Tools
KUBERNETES_YAML_PROMPTKUBERNETES_QUERY_PROMPTTROUBLESHOOT_PODS_PROMPTTROUBLESHOOT_NODES_PROMPTTROUBLESHOOT_NETWORK_PROMPT
5. Metrics Tools
GET_NODE_METRICSGET_POD_METRICSGET_RESOURCE_METRICSGET_TOP_CONSUMERS
Architecture (k8s-style group/version)
cmd/kubernetes-mcp/
main.go
app/
pkg/
client/kubernetes/
config/
handlers/
apis/
core/v1/
apps/v1/
base/
tool/
prompt/
metrics/
server/
health/
logger/
Docker
Build:
docker build -t kubernetes-mcp:latest .
Run with explicit transport command:
docker run --rm -it \
-v ~/.kube:/root/.kube \
kubernetes-mcp:latest \
server transport stdio --kubeconfig /root/.kube/config
Kubernetes Deployment
Deployment manifests are in /deploy/kubernetes.
make k8s-deploy
# or
make k8s-deploy-kustomize
Development
make build
make test
Justfile + One-Click Skill Install
This repo includes a project usage skill at skills/kubernetes-mcp-usage.
# list just tasks
just
# common dev tasks
just build
just test
# install the project skill into Codex
just skill-install
# overwrite existing install
just skill-install-force
Skill install destination:
$CODEX_HOME/skills/kubernetes-mcp-usage (or ~/.codex/skills/kubernetes-mcp-usage when CODEX_HOME is not set).
After installing, restart Codex to pick up the skill.
Notes
- Resource operations depend on your cluster API availability and RBAC permissions.
- For network transports behind ingress/reverse proxy, set
--base-urlcorrectly for SSE.
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.