k8s-mcp-server
This server provides read-only Kubernetes diagnostics through MCP tools.
List all namespaces in the cluster
List pods in a namespace with lifecycle phase and IP, optionally filtered by label selector
Retrieve pod logs with configurable tail lines and container selection
List cluster events, with optional namespace scope and warning-only filtering
List deployments with desired vs. available replica counts
List services with type and exposed ports
All operations are strictly read-only and avoid exposing secrets or config maps
Provides read-only tools for inspecting and diagnosing Kubernetes clusters, including listing pods and retrieving pod logs.
k8s-mcp-server
Production-ready Kubernetes diagnostics and cluster observability MCP server for AI agents.
What is this?
k8s-mcp-server is a Model Context Protocol (MCP) server providing automated, read-only diagnostic tools for inspecting Kubernetes clusters. It allows AI agents to troubleshoot pod crashes, inspect ingress routes, and analyze cluster-wide warning events safely.
Related MCP server: Kubernetes Tools MCP Server
Available Tools
Tool | Category | Description |
| Infrastructure | Lists nodes, readiness states, roles, and kubelet versions. |
| Workloads | Detects abnormal pod phases, restart loops, and CrashLoopBackOffs. |
| Observability | Retrieves container stdout/stderr logs with tail limits and crash inspection. |
| Diagnostics | Aggregates FailedScheduling, FailedMount, and BackOff warning events. |
| Networking | Audits HTTP routing rules, host headers, and TLS certificates. |
Quick Start
Prerequisites
Python 3.11+
Active Kubernetes cluster access (
~/.kube/configor in-cluster ServiceAccount)Read-only RBAC privileges (
get,liston core and networking API groups)
Run Locally
git clone https://github.com/akkireddy-challa/k8s-mcp-server.git
cd k8s-mcp-server
pip install -r requirements.txt
python server.pyClaude Desktop Configuration
Add to claude_desktop_config.json:
{
"mcpServers": {
"kubernetes": {
"command": "python",
"args": ["/path/to/k8s-mcp-server/server.py"],
"env": {
"KUBECONFIG": "/Users/<username>/.kube/config"
}
}
}
}Security Model
Strictly Read-Only: Enforces GET and LIST operations only.
Zero-Secret Exposure: Secrets and config maps are never inspected or surfaced to LLM context.
Flexible Auth: Supports standard
~/.kube/configcontext or in-cluster pod ServiceAccounts.
License
MIT License. See LICENSE for details.
Built by Akkireddy Challa — Platform Engineer at Telia, Stockholm.
Available Tools
6 toolsget_cluster_eventsA
Retrieve Kubernetes cluster events to diagnose scheduling failures, node pressure, or eviction warnings.
Usage Guidelines
Call this tool when pods remain stuck in 'Pending' or 'CrashLoopBackOff' states.
Use
warning_only=Trueto eliminate normal informational noise during triage.
Behavioral Transparency
Read-only query.
Returns up to the 50 most recent events formatted with event type, target resource, reason, and message.
Inputs: namespace, warning_only. Returns: result
get_pod_logsA
Extract stdout and stderr log streams from a pod container for diagnostics.
Usage Guidelines
Use when investigating application crashes, HTTP 500 errors, or startup exceptions.
Keep
tail_linessmall (e.g. 50–200) to avoid overloading LLM token context.
Behavioral Transparency
Read-only query.
Returns raw text log lines or a descriptive error if the pod or container does not exist.
Inputs: pod_name (required), container, namespace, tail_lines. Returns: result
list_deploymentsA
List deployments in a namespace with desired vs available replica counts.
Usage Guidelines
Use this tool to verify rollout status and check whether workloads meet desired scale.
When replicas show 0 available, use
list_podsandget_cluster_eventsto locate the failure.
Behavioral Transparency
Read-only operation using AppsV1Api.
Returns name, desired replicas, and ready replica count.
Inputs: namespace. Returns: result
list_namespacesA
List all namespaces present in the connected Kubernetes cluster.
Usage Guidelines
Call this tool first when discovering available cluster domains or when the user does not supply an explicit namespace.
Do not use this tool to inspect workload health; use
list_podsinstead.
Behavioral Transparency
Read-only operation.
Scans cluster-wide namespace resources using CoreV1Api.
Returns an alphabetically sorted list of namespace names with total count.
Inputs: no named parameters. Returns: result
list_podsA
List pods within a specified namespace along with their lifecycle phase and IP address.
Usage Guidelines
Use this tool when identifying running workloads, crash loops, or verifying pod readiness.
If troubleshooting a failing pod, pass its name to
get_pod_logsor callget_cluster_events.
Behavioral Transparency
Read-only operation.
Omits internal container state arrays; highlights high-level phase (Running, Pending, Failed).
Inputs: namespace, label_selector. Returns: result
list_servicesA
List Kubernetes services, exposed ports, and service types within a namespace.
Usage Guidelines
Use this tool when checking network ingress, internal DNS resolution, or service endpoints.
Complement with
list_podsto confirm underlying backend endpoints exist.
Behavioral Transparency
Read-only query using CoreV1Api.
Lists service name, type (ClusterIP, NodePort, LoadBalancer), and mapped ports.
Inputs: namespace. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool targets a distinct Kubernetes resource or action: namespaces, pods, logs, events, deployments, and services. No functional overlap that would confuse tool selection.
Names follow a consistent lowercase snake_case verb_noun pattern, but four use 'list_' while two use 'get_'. The split is semantically reasonable yet not perfectly uniform.
Six tools form a focused, readable set for read-only Kubernetes inspection and troubleshooting, without redundant or excessive entries.
The set covers the core resources needed for workload troubleshooting: namespaces, pods, logs, cluster events, deployments, and services. There are no obvious dead ends for the inferred read-only diagnostic domain.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
The Google GKE MCP server is a managed Model Context Protocol server that provides AI applications with tools to manage Google Kubernetes Engine (GKE) clusters and Kubernetes resources. It exposes a structured, discoverable interface that allows AI agents to interact with GKE and Kubernetes APIs, enabling them to inspect cluster configurations, retrieve Kubernetes resource YAMLs, monitor operations like cluster upgrades, diagnose issues, and optimize costs—all without needing to parse text output or use complex kubectl commands.
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceA Model Context Protocol server that enables AI assistants to interact with Kubernetes clusters through natural language, supporting core Kubernetes operations, monitoring, security, and diagnostics.140 npm974MIT
- AlicenseAqualityAmaintenanceProvides a set of read-only Kubernetes functions via an MCP server, enabling interaction with Kubernetes clusters through agents or coding assistants like GitHub Copilot.21257 PyPI3Apache 2.0
- AlicenseNot gradedqualityDmaintenanceModel Context Protocol server that standardizes tool discovery, execution, and context management for AI applications.MIT
- FlicenseNot gradedqualityDmaintenanceAn Model Context Protocol server that lets language models directly manage and visualize Kubernetes clusters through safe, high-level operational tools.1-