- Home
- MCP servers
- Kubernetes
Kubernetes
- python
0
GitHub Stars
python
Language
7 months ago
First Indexed
3 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"kishanrao92-infra-mcp": {
"command": "python3",
"args": [
"server.py"
],
"env": {
"KUBECONFIG": "/path/to/kubeconfig",
"OPENAI_API_KEY": "YOUR_API_KEY"
}
}
}
}You can run an MCP server that exposes Kubernetes cluster data via a Flask-based interface and query it with natural language. This setup lets you diagnose issues, inspect pods, events, and logs, and get actionable insights through an interactive client or concise one-shot questions.
How to use
Launch the server and connect with the interactive client to ask questions like which pods are failing, what is the status of a service, or summarize recent errors. The client translates your natural language questions into actionable checks against the Kubernetes cluster and returns structured results with evidence and suggested next steps.
Typical usage patterns include asking about pod health across namespaces, drilling into detailed pod information, reviewing recent changes in deployments, and analyzing error rates or traces for a service. You can also ask for quick summaries of cluster events within a specific time window.
How to install
Prerequisites: Python 3.9 or higher, a Kubernetes cluster (KIND recommended for local testing), and an OpenAI API key if you want language-model features.
Install and run the MCP server locally by following these steps.
# 1) Set up your environment
export OPENAI_API_KEY="your-api-key-here" # Optional
export KUBECONFIG="path/to/your/kubeconfig" # If not using the default kubeconfig
# 2) Install Python dependencies
pip install flask kubernetes openai requests
# 3) Start the server (in the mcp directory)
python3 server.py
Configuration
Environment variables you may use when running the server include OPENAI_API_KEY for LLM features and KUBECONFIG to specify your Kubernetes configuration.
{
"mcpServers": [
{
"name": "k8s_mcp",
"type": "stdio",
"command": "python3",
"args": ["server.py"],
"env": [
{"name": "OPENAI_API_KEY", "value": "YOUR_API_KEY"},
{"name": "KUBECONFIG", "value": "/path/to/kubeconfig"}
]
}
],
"envVars": [
{"name": "OPENAI_API_KEY", "description": "OpenAI API key for LLM features", "example": "YOUR_API_KEY"},
{"name": "KUBECONFIG", "description": "Path to your kubeconfig file", "example": "/home/user/.kube/config"}
]
}
Troubleshooting
If the server fails to start, verify that Python 3.9+ is installed, the required packages are available, and that the kubeconfig path is valid. Check for common issues such as network access to the Kubernetes cluster, proper permissions, and whether the OpenAI API key is set when you expect language-model features.
Available tools
k8s.listProblemPods
Identify problematic pods based on status, restarts, and events to quickly surface issues needing investigation.
k8s.getPodDetails
Retrieve detailed information for a specific pod including status, containers, and recent logs.
deployments.listRecentChanges
Show recent deployment history to correlate changes with observed issues.
metrics.getErrors
Analyze error rates over a time window to highlight spikes and failures.
traces.sampleErrors
Provide sample traces of failing requests to aid debugging.
config.getDiff
Compare current configuration changes and highlight differences.