thoraxe/kube-health-mcp
If you are the rightful owner of kube-health-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Kube-Health MCP Server is a tool for investigating the health of Kubernetes objects using the Model Context Protocol.
kube_health
Investigate the health of a Kubernetes object using the kube-health tool.
Kube-Health MCP Server
This project implements an MCP (Model Context Protocol) server that exposes the kube-health
tool for investigating Kubernetes object health.
Overview
The MCP server provides a single tool called kube_health
that allows you to investigate the health status of Kubernetes objects by specifying the object name (e.g., deployment/my-app
, pod/my-pod
, service/my-service
).
Prerequisites
- Python 3.8 or higher
- The
kube-health
binary in thebin/
directory (included) - Access to a Kubernetes cluster (configured via kubeconfig)
Installation
-
Install the required dependencies:
pip install -r requirements.txt
-
Make sure the
kube-health
binary is executable:chmod +x bin/kube-health
Usage
Running the MCP Server
The server can be run in different modes depending on your needs:
STDIO Mode (Default)
For local tools and Claude Desktop integration:
python server.py
HTTP Mode
For web deployments and remote access:
# Using environment variables
MCP_TRANSPORT=http MCP_PORT=9000 python server.py
# Or using a .env file
echo "MCP_TRANSPORT=http" > .env
echo "MCP_PORT=9000" >> .env
python server.py
Custom Configuration
Set environment variables for custom configuration:
export MCP_TRANSPORT=http
export MCP_HOST=0.0.0.0
export MCP_PORT=8080
export MCP_PATH=/kube-health/
export MCP_LOG_LEVEL=debug
python server.py
The server will start and listen for MCP client connections using the FastMCP library.
Using the Tool
The server exposes one tool:
kube_health
Description: Investigate the health of a Kubernetes object using the kube-health tool.
Parameters:
object_name
(string): The Kubernetes object to investigate
Examples:
deployment/my-app
- Check health of a deployment named "my-app"pod/my-pod
- Check health of a pod named "my-pod"service/my-service
- Check health of a service named "my-service"namespace/my-namespace
- Check health of a namespace named "my-namespace"
Transport
This server supports the Streamable HTTP transport as specified in the MCP specification. The FastMCP library handles the transport layer automatically.
Configuration
Environment Variables
The server can be configured using environment variables. Copy example.env
to .env
and modify as needed:
cp example.env .env
Available Environment Variables:
Variable | Default | Description |
---|---|---|
MCP_TRANSPORT | stdio | Transport type: stdio , http , or sse |
MCP_HOST | 127.0.0.1 | Host to bind to (http/sse only) |
MCP_PORT | 8000 | Port to listen on (http/sse only) |
MCP_PATH | /mcp/ | Path for MCP endpoint (http/sse only) |
MCP_LOG_LEVEL | info | Logging level: debug , info , warning , error |
Transport Types:
stdio
(default): Standard input/output communication (recommended for local tools and Claude Desktop)http
: Streamable HTTP transport (recommended for web deployments and remote access)sse
: Server-Sent Events transport (deprecated, usehttp
instead)
Kubernetes Configuration
The server will use your existing Kubernetes configuration (kubeconfig) to connect to your cluster. Make sure you have:
- A valid kubeconfig file (usually at
~/.kube/config
) - Proper permissions to access the Kubernetes resources you want to monitor
You can also set Kubernetes-specific environment variables:
KUBECONFIG
: Path to your kubeconfig file- Standard Kubernetes environment variables for in-cluster access
Troubleshooting
- "kube-health binary not found": Ensure the
bin/kube-health
file exists and is in the correct location - "binary is not executable": Run
chmod +x bin/kube-health
to make it executable - Connection errors: Verify your kubeconfig is properly configured and you have access to the cluster
- Timeout errors: The tool has a 30-second timeout; complex queries on large clusters may need adjustment
Development
The server is built using the FastMCP library, which provides a simple way to create MCP servers in Python. The main implementation is in server.py
.
To modify or extend the server:
- Edit
server.py
to add new tools or modify existing ones - Use the
@mcp.tool()
decorator to register new tools - Follow the MCP specification for tool definitions and responses