K8s MCP Server
@christian-schlichtherle
About K8s MCP Server
An MCP server for comprehensive access to one or more Kubernetes clusters
Basic information
Category
Cloud & Infrastructure
Transports
stdio
Publisher
christian-schlichtherle
Submitted by
Christian Schlichtherle
Config
Add this server to your MCP-compatible client using the configuration below.
{
"mcpServers": {
"k8s": {
"command": "uv",
"args": [
"--directory",
"/path/to/k8s-mcp",
"run",
"k8s-mcp"
],
"env": {
"KUBECONFIG_ALIASES": "development=dev production=prod",
"KUBECONFIG_URLS": "dev=file:///path/to/development/k3s/kubeconfig.yaml prod=file:///path/to/production/k3s/kubeconfig.yaml",
"PORT_FORWARD_CONFIG_URL": "file:///path/to/k8s-mcp/port-forward-config.yaml"
}
}
}
}Tools
No tools detected
We auto-extract tools from the README. The maintainer can list them under a ## Tools heading to populate this section.
Overview
What is K8s MCP Server?
K8s MCP Server is an AI-friendly Kubernetes access tool that supports enhanced port‑forward management, headless services, and kubectl‑inspired output formats. It is designed for AI agents and developers who need efficient, context‑aware interaction with Kubernetes clusters.
How to use K8s MCP Server?
Install dependencies with pip install -e ., set environment variables such as KUBECONFIG_URLS and PORT_FORWARD_CONFIG_URL, then run python main.py. The server provides MCP tools for reading, modifying, and discovering resources, along with port‑forward session management.
Key features of K8s MCP Server
- kubectl‑inspired output formats (table, wide, json, yaml, custom‑columns, jsonpath)
- Natural‑language resource kind discovery for CRDs and built‑in resources
- URL‑based port‑forward configuration via local files or GitHub Gists
- Headless service support with direct pod targeting via label selectors
- Token‑efficient AI‑optimized output and multi‑format config files (YAML, JSON, TOML)
- In‑memory port‑forward session tracking with list and teardown capabilities
Use cases of K8s MCP Server
- AI agents perform cluster overview, application debugging, and safe deployment updates
- Automated port‑forward setup for AI workflows (e.g., connecting to a Druid service in development)
- Resource cleanup and security audits using read‑only or modify tools
- Performance troubleshooting and disaster recovery with structured tool workflows
- Multi‑cluster resource discovery and exploration without manual kubectl commands
FAQ from K8s MCP Server
What Kubernetes resources can I list or query?
You can list pods, services, deployments, nodes, events, and any custom resource kind discovered via discover_resource_kinds. The server supports plural, singular, and abbreviated resource names (e.g., pods, pod, po), and case‑insensitive input.
How does the port‑forward configuration work?
Port‑forward targets are defined in a YAML/JSON/TOML file, referenced by PORT_FORWARD_CONFIG_URL. Each target specifies a cluster alias, namespace, label selectors, local port, and remote port. The AI agent can then use connect_to_service_targets to set up the forward.
Are the tools safe for autonomous AI use?
Tools are classified into three safety levels: [READ-ONLY] (safe for autonomous use, e.g., list_resources, get_logs), [MODIFIES STATE] (require user approval, e.g., apply_manifest, connect_to_service_targets), and [DANGEROUS] (require explicit confirmation, e.g., delete_resource, execute_in_pod).
Does K8s MCP Server support headless services?
Yes. For headless services, the server selects the first ready pod using label selectors, mimicking kubectl port-forward behavior. This is configured in the port‑forward config file under each service target.
What transport or authentication does the server use?
The server uses the MCP stdio transport and relies on existing Kubernetes authentication (kubeconfig) configured via the KUBECONFIG_URLS environment variable. It does not implement additional authentication layers.
More Cloud & Infrastructure MCP servers
Mcp K8s Go
strowkMCP server connecting to Kubernetes
Query | MCP server for Supabase
alexander-zuevQuery MCP enables end-to-end management of Supabase via chat interface: read & write query executions, management API support, automatic migration versioning, access to logs and much more.
🐋 Docker MCP server
ckreilingMCP server for Docker
MCP Server Kubernetes
Flux159MCP Server for kubernetes management commands
AWS Model Context Protocol (MCP) Server
alexei-ledA lightweight service that enables AI assistants to execute AWS CLI commands (in safe containerized environment) through the Model Context Protocol (MCP). Bridges Claude, Cursor, and other MCP-aware AI tools with AWS CLI for enhanced cloud infrastructure management.
Comments