loading…
Search for a command to run...
loading…
A lightweight MCP server that enables AI assistants to deploy, inspect, and operate Kubernetes workloads through high-level workflow tools, reducing token usage
A lightweight MCP server that enables AI assistants to deploy, inspect, and operate Kubernetes workloads through high-level workflow tools, reducing token usage with structured outputs.
AI-native Kubernetes operations for agents and fast-moving teams.
k8s-mcp is a lightweight MCP server that lets AI assistants deploy, inspect, and operate Kubernetes workloads through high-level workflow tools instead of raw kubectl commands — with structured outputs that significantly reduce token usage.
Works with Claude Code · Codex CLI · Gemini CLI · Opencode · and any MCP-compatible agent.
Less kubectl. More done.
AI assistants today can suggest kubectl commands. But actually operating a cluster still means switching contexts, copy-pasting commands, manually debugging failures, and repeatedly checking logs and events. That creates a slow human-in-the-loop cycle.
k8s-mcp closes this gap by giving AI agents task-complete tools instead of low-level primitives. Instead of chaining:
kubectl get pod
kubectl describe pod
kubectl logs
agents can call tools like diagnose_pod() or wait_for_ready() — and get structured results in one shot.
k8s-mcp is designed around workflows, not raw resource access — optimized for:
diagnose_pod combines status, conditions, events, and failing-container logs into a single report~/.kube/config and your organization's existing auth flow (SSO, OIDC, certificate). Never stores or manages credentialsSome Kubernetes MCP servers focus on broad resource-level API access. k8s-mcp focuses on workflow-level tools designed for AI agents.
| k8s-mcp | Traditional MCP servers | |
|---|---|---|
| Focus | Workflow-level tools | Raw resource APIs |
| Usability | Beginner-friendly | Kubernetes expertise required |
| Outputs | Summarized, structured | Raw API responses |
| Agent efficiency | High — fewer calls, lower token usage | Requires more reasoning and chaining |
If you want broad, low-level Kubernetes API access, there are other MCP servers better suited for that. If you want an agent that can actually operate a cluster with less manual overhead, this project is for you.
git clone [email protected]:jingyanjiang/k8s-mcp.git
cd k8s-mcp
pipx install .
This puts k8s-mcp on your PATH and works from any directory.
You can also use uv tool install . or pip install .. For development, use poetry install.
k8s-mcp reads your existing ~/.kube/config. Before using it, verify:
kubectl auth whoami
kubectl get all -n <your-namespace>
The server inherits whatever permissions your kubeconfig user has. No additional credentials are needed.
Note: Some operations (e.g.,
list_namespaces,list_nodes) require cluster-wide permissions. If a request fails with403 Forbidden, ask your cluster admin for the necessary RBAC roles.
Add to .mcp.json (project-level) or ~/.claude.json (global):
{
"mcpServers": {
"k8s": {
"type": "stdio",
"command": "k8s-mcp",
"args": ["--transport", "stdio"]
}
}
}
Add to ~/.codex/config.toml (user-level) or .codex/config.toml (project-level):
[mcp_servers.k8s]
command = "k8s-mcp"
args = ["--transport", "stdio"]
Add to ~/.gemini/settings.json (user-level) or .gemini/settings.json (project-level):
{
"mcpServers": {
"k8s": {
"command": "k8s-mcp",
"args": ["--transport", "stdio"]
}
}
}
Add to opencode.json in your project root:
{
"mcp": {
"k8s": {
"type": "local",
"command": ["k8s-mcp", "--transport", "stdio"]
}
}
}
If your MCP client can't find
k8s-mcpon PATH, use the absolute path instead (runwhich k8s-mcpto find it).
The server starts automatically when your MCP client connects — no manual commands needed.
Replace "command": "k8s-mcp" with "command": "poetry" and set args to ["run", "k8s-mcp", "--transport", "stdio"]. You must also add "cwd": "/absolute/path/to/k8s-mcp" so Poetry can find the project.
The server supports three transport modes:
# stdio (for local MCP clients like Claude Code)
k8s-mcp --transport stdio
# Streamable HTTP (for remote/networked clients)
k8s-mcp --transport streamable-http
# SSE (Server-Sent Events)
k8s-mcp --transport sse
For HTTP transports, configure bind address and port via environment variables:
export K8S_MCP_HOST=0.0.0.0 # default: localhost
export K8S_MCP_PORT=8000 # default: 8000
k8s-ops skill for Claude CodeFor Claude Code users, this repo ships an opinionated workflow skill at skills/k8s-ops/. It encodes multi-step playbooks for deploy, debug, rollout, and audit on top of the raw MCP tools — useful when you want the agent to follow a tested sequence (e.g., debug decision tree, pre-flight rollout checks) rather than improvise.
Install with a symlink so updates from git pull flow through automatically:
ln -s "$(pwd)/skills/k8s-ops" ~/.claude/skills/k8s-ops
Then in Claude Code, invoke it with /k8s-ops (e.g., /k8s-ops debug, /k8s-ops audit NAMESPACE=foo). The skill is also model-invoked — it activates automatically when you ask the agent to deploy, diagnose, restart, or audit Kubernetes workloads.
Skip this step if you're using a different MCP client. The MCP server itself works without it.
Please check the status of my namespace: <namespace>
Please deploy the app in this repo to my k8s cluster. Make a plan first, then implement it.
My pods in namespace X keep crashing. Can you figure out what's wrong?
"Please check the status of my namespace: xxxxx"
The assistant will list pods, deployments, services, and events in the namespace, surfacing any issues it finds.

"Please deploy the app/server in this repo to a k8s cluster for me. Make a plan first, then implement it."
The agent will:
"My pods in namespace X keep crashing. Can you figure out what's wrong?"
The agent will inspect pod status, conditions, events, and container logs — then return a structured explanation with suggested fixes. No more manually running describe and logs in a loop.
These best represent the project's workflow-oriented design:
| Tool | Description |
|---|---|
diagnose_pod |
One-shot diagnostics — combines status, conditions, events, and failing-container logs |
wait_for_ready |
Poll a pod or deployment until ready or timeout (enables autonomous deploy loops) |
apply_manifest |
Apply YAML manifests (create or update, supports multi-document) |
apply_kustomize |
Render and apply a Kustomize directory (equivalent to kubectl apply -k) |
get_resource_yaml |
Export a live resource as clean YAML (for config drift detection) |
generate_deploy_manifests |
Generate Kubernetes manifests for deploying k8s-mcp itself to a cluster |
All operations are exposed as MCP tools — you interact with them conversationally through your AI assistant.
| Tool | Description |
|---|---|
get_contexts |
List available kubeconfig contexts |
get_current_context |
Show the active context, cluster, and user |
| Tool | Description |
|---|---|
list_namespaces |
List all namespaces in the cluster |
| Tool | Description |
|---|---|
list_pods |
List pods (by namespace, label, or all namespaces) |
get_pod |
Get detailed pod information |
get_pod_logs |
Fetch container logs (with tail, previous container support) |
delete_pod |
Delete a pod (with configurable grace period) |
diagnose_pod |
One-shot diagnostics — combines status, conditions, events, and logs from failing containers |
exec_command |
Execute a command inside a running container (e.g., curl, env, nslookup) |
| Tool | Description |
|---|---|
list_deployments |
List deployments (by namespace, label, or all namespaces) |
get_deployment |
Get detailed deployment information |
scale_deployment |
Scale a deployment to N replicas |
restart_deployment |
Rolling restart (equivalent to kubectl rollout restart) |
get_rollout_status |
Check if a rollout is complete, in progress, or stuck |
| Tool | Description |
|---|---|
list_services |
List services (by namespace, label, or all namespaces) |
get_service |
Get detailed service information |
| Tool | Description |
|---|---|
list_configmaps |
List ConfigMaps (by namespace, label, or all namespaces) |
get_configmap |
Get a ConfigMap's metadata and data contents |
| Tool | Description |
|---|---|
list_secrets |
List Secrets with type and key counts |
get_secret |
Get Secret metadata and key names; optionally decode values with masking |
| Tool | Description |
|---|---|
list_service_accounts |
List ServiceAccounts (by namespace, label, or all namespaces) |
get_service_account |
Get ServiceAccount details including secrets and automount config |
| Tool | Description |
|---|---|
list_roles |
List Roles (by namespace or all); optionally include ClusterRoles |
get_role |
Get Role or ClusterRole details including permission rules |
list_role_bindings |
List RoleBindings (by namespace or all); optionally include ClusterRoleBindings |
get_role_binding |
Get RoleBinding or ClusterRoleBinding details including subjects and role reference |
| Tool | Description |
|---|---|
list_nodes |
List cluster nodes with status and roles |
get_node |
Get detailed node information |
| Tool | Description |
|---|---|
list_events |
List events, optionally filtered by resource name |
| Tool | Description |
|---|---|
list_jobs |
List jobs with completion status and duration |
| Tool | Description |
|---|---|
list_ingresses |
List Ingresses with hosts, class, and TLS info |
get_ingress |
Get detailed Ingress information including routing rules |
| Tool | Description |
|---|---|
apply_manifest |
Apply YAML manifests (create or update, supports multi-document) |
apply_kustomize |
Render and apply a Kustomize directory (equivalent to kubectl apply -k) |
delete_resource |
Delete any resource by type and name (supports abbreviations like po, svc, deploy) |
describe_resource |
Describe any resource — combines spec/status with related events (like kubectl describe) |
get_resource_yaml |
Export a live resource as clean YAML (for config drift detection) |
| Tool | Description |
|---|---|
top_pods |
Show CPU/memory usage per pod (requires metrics-server) |
top_nodes |
Show CPU/memory usage per node with capacity percentages |
| Tool | Description |
|---|---|
wait_for_ready |
Poll a pod or deployment until ready or timeout (enables autonomous deploy loops) |
| Tool | Description |
|---|---|
generate_deploy_manifests |
Generate Kubernetes manifests for deploying k8s-mcp itself to a cluster |
k8s-mcp is designed with practical safeguards:
Always review actions before applying changes in production environments.
This project is actively maintained and evolving. Feedback, suggestions, and contributions are welcome.
Pull requests and ideas are welcome. If you're experimenting with AI-driven DevOps, I'd love to hear what workflows would be useful.
MIT
Выполни в терминале:
claude mcp add k8s-mcp -- npx Безопасность
Низкий рискАвтоматическая эвристика по публичным данным — не гарантия безопасности.