kubernetes-mcp
A Model Context Protocol (MCP) server that provides safe, read-only access to Kubernetes resources for debugging and inspection. Built with security in mind, it offers comprehensive cluster visibility without modification capabilities.
README
Kubernetes MCP Server
https://github.com/user-attachments/assets/89df70b0-65d1-461c-b4ab-84b2087136fa
A Model Context Protocol (MCP) server that provides safe, read-only access to Kubernetes resources for debugging and inspection. Built with security in mind, it offers comprehensive cluster visibility without modification capabilities.
Features
- 🔒 Read-only security: Safely inspect Kubernetes resources without modification capabilities
- 🎯 CRD support: Works seamlessly with any Custom Resource Definitions in your cluster
- 🔍 Smart discovery: Find resources by API group substring (e.g., "flux" for FluxCD, "argo" for ArgoCD)
- ⚡ High performance: Efficient resource querying with filtering and pagination
- 🛠️ Comprehensive toolset:
list_resources: List and filter Kubernetes resources with advanced optionsdescribe_resource: Get detailed information about specific resourcesget_pod_logs: Retrieve pod logs with sophisticated filtering capabilitieslist_events: List and filter Kubernetes events for debugging and monitoring
🚀 Quick Start
Prerequisites
- Kubernetes cluster access with a valid kubeconfig file
- Go 1.24+ (for building from source)
Installation Options
Option 1: Install with Go (Recommended)
go install github.com/kkb0318/kubernetes-mcp@latest
The binary will be available at $GOPATH/bin/kubernetes-mcp (or $HOME/go/bin/kubernetes-mcp if GOPATH is not set).
Option 2: Build from Source
git clone https://github.com/kkb0318/kubernetes-mcp.git
cd kubernetes-mcp
go build -o kubernetes-mcp .
⚙️ Configuration
MCP Server Setup
Add the server to your MCP configuration:
Basic Configuration
Uses ~/.kube/config automatically:
{
"mcpServers": {
"kubernetes": {
"command": "/path/to/kubernetes-mcp"
}
}
}
Custom Kubeconfig
{
"mcpServers": {
"kubernetes": {
"command": "/path/to/kubernetes-mcp",
"env": {
"KUBECONFIG": "/path/to/your/kubeconfig"
}
}
}
}
Note: Replace
/path/to/kubernetes-mcpwith your actual binary path.
Standalone Usage
# Default kubeconfig (~/.kube/config)
./kubernetes-mcp
# Custom kubeconfig path
KUBECONFIG=/path/to/your/kubeconfig ./kubernetes-mcp
Important: Ensure you have appropriate read permissions for the Kubernetes resources you want to inspect.
🛠️ Available Tools
list_resources
List and filter Kubernetes resources with advanced capabilities.
| Parameter | Type | Description |
|---|---|---|
kind |
required | Resource type (Pod, Deployment, Service, etc.) or "all" for discovery |
groupFilter |
optional | Filter by API group substring for project-specific resources |
namespace |
optional | Target namespace (defaults to all namespaces) |
labelSelector |
optional | Filter by labels (e.g., "app=nginx") |
fieldSelector |
optional | Filter by fields (e.g., "metadata.name=my-pod") |
limit |
optional | Maximum number of resources to return |
timeoutSeconds |
optional | Request timeout (default: 30s) |
showDetails |
optional | Return full resource objects instead of summary |
Examples:
// List pods with label selector
{
"kind": "Pod",
"namespace": "default",
"labelSelector": "app=nginx"
}
// Discover FluxCD resources
{
"kind": "all",
"groupFilter": "flux"
}
describe_resource
Get detailed information about a specific Kubernetes resource.
| Parameter | Type | Description |
|---|---|---|
kind |
required | Resource type (Pod, Deployment, etc.) |
name |
required | Resource name |
namespace |
optional | Target namespace |
Example:
{
"kind": "Pod",
"name": "nginx-pod",
"namespace": "default"
}
get_pod_logs
Retrieve pod logs with sophisticated filtering options.
| Parameter | Type | Description |
|---|---|---|
name |
required | Pod name |
namespace |
optional | Pod namespace (defaults to "default") |
container |
optional | Specific container name |
tail |
optional | Number of lines from the end (default: 100) |
since |
optional | Duration like "5s", "2m", "3h" |
sinceTime |
optional | RFC3339 timestamp |
timestamps |
optional | Include timestamps in output |
previous |
optional | Get logs from previous container instance |
Example:
{
"name": "nginx-pod",
"namespace": "default",
"tail": 50,
"since": "5m",
"timestamps": true
}
list_events
List and filter Kubernetes events with advanced filtering options for debugging and monitoring.
| Parameter | Type | Description |
|---|---|---|
namespace |
optional | Target namespace (leave empty for all namespaces) |
object |
optional | Filter by object name (e.g., pod name, deployment name) |
eventType |
optional | Filter by event type: "Normal" or "Warning" (case-insensitive) |
reason |
optional | Filter by event reason (e.g., "Pulled", "Failed", "FailedScheduling") |
since |
optional | Duration like "5s", "2m", "1h" |
sinceTime |
optional | RFC3339 timestamp (e.g., "2025-06-20T10:00:00Z") |
limit |
optional | Maximum number of events to return (default: 100) |
timeoutSeconds |
optional | Request timeout (default: 30s) |
Examples:
// List recent warning events
{
"eventType": "Warning",
"since": "30m"
}
// List events for a specific pod
{
"object": "nginx-pod",
"namespace": "default"
}
// List failed scheduling events
{
"reason": "FailedScheduling",
"limit": 50
}
🌟 Advanced Features
🎯 Custom Resource Definition (CRD) Support
Automatically discovers and works with any CRDs in your cluster. Simply use the CRD's Kind name with list_resources or describe_resource tools.
🔍 Smart Resource Discovery
Use the groupFilter parameter to discover resources by API group substring:
| Filter | Discovers | Examples |
|---|---|---|
"flux" |
FluxCD resources | HelmReleases, Kustomizations, GitRepositories |
"argo" |
ArgoCD resources | Applications, AppProjects, ApplicationSets |
"istio" |
Istio resources | VirtualServices, DestinationRules, Gateways |
"cert-manager" |
cert-manager resources | Certificates, Issuers, ClusterIssuers |
🔒 Security & Safety
Built with security as a primary concern:
- ✅ Read-only access - No resource creation, modification, or deletion
- ✅ Production safe - Secure for use in production environments
- ✅ Minimal permissions - Only requires read access to cluster resources
- ✅ No destructive operations - Cannot harm your cluster
🤝 Contributing
We welcome contributions! Please ensure all changes maintain the read-only nature of the server and include appropriate tests.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。