Logo Kubernetes MCP 服务器

Kubernetes MCP 服务器

Cộng đồng
kkb0318

https://github.com/user-attachments/assets/89df70b0-65d1-461c-b4ab-84b2087136fa

Nhà phát hànhkkb0318
Kho mãkubernetes-mcp
Ngôn ngữGo
Bản fork
8
Sao
43
Công cụ có sẵn
0
Phương thức truyền tảistdio
Danh mục
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    Kubernetes MCP 服务器 cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    43 sao và 8 bản fork từ kho mã được liên kết.

Kubernetes MCP Server

tests codecov License: MIT

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
  • 🌐 Multi-cluster support: Switch between different Kubernetes contexts seamlessly
  • 🔍 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 options
    • describe_resource: Get detailed information about specific resources
    • get_pod_logs: Retrieve pod logs with sophisticated filtering capabilities
    • list_events: List and filter Kubernetes events for debugging and monitoring
    • list_contexts: List all available Kubernetes contexts from kubeconfig

🚀 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)

bash
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

bash
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:

json
{
  "mcpServers": {
    "kubernetes": {
      "command": "/path/to/kubernetes-mcp"
    }
  }
}

Custom Kubeconfig

json
{
  "mcpServers": {
    "kubernetes": {
      "command": "/path/to/kubernetes-mcp",
      "env": {
        "KUBECONFIG": "/path/to/your/kubeconfig"
      }
    }
  }
}

Note: Replace /path/to/kubernetes-mcp with your actual binary path.

Standalone Usage

bash
# 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.

ParameterTypeDescription
contextoptionalKubernetes context name from kubeconfig (leave empty for current context)
kindrequiredResource type (Pod, Deployment, Service, etc.) or "all" for discovery
groupFilteroptionalFilter by API group substring for project-specific resources
namespaceoptionalTarget namespace (defaults to all namespaces)
labelSelectoroptionalFilter by labels (e.g., "app=nginx")
fieldSelectoroptionalFilter by fields (e.g., "metadata.name=my-pod")
limitoptionalMaximum number of resources to return
timeoutSecondsoptionalRequest timeout (default: 30s)
showDetailsoptionalReturn full resource objects instead of summary

Examples:

json
// List pods with label selector
{
  "kind": "Pod",
  "namespace": "default",
  "labelSelector": "app=nginx"
}

// List pods from a specific cluster context
{
  "kind": "Pod",
  "context": "production-cluster",
  "namespace": "default"
}

// Discover FluxCD resources
{
  "kind": "all",
  "groupFilter": "flux"
}

describe_resource

Get detailed information about a specific Kubernetes resource.

ParameterTypeDescription
contextoptionalKubernetes context name from kubeconfig (leave empty for current context)
kindrequiredResource type (Pod, Deployment, etc.)
namerequiredResource name
namespaceoptionalTarget namespace

Example:

json
{
  "kind": "Pod",
  "name": "nginx-pod",
  "namespace": "default"
}

get_pod_logs

Retrieve pod logs with sophisticated filtering options.

ParameterTypeDescription
contextoptionalKubernetes context name from kubeconfig (leave empty for current context)
namerequiredPod name
namespaceoptionalPod namespace (defaults to "default")
containeroptionalSpecific container name
tailoptionalNumber of lines from the end (default: 100)
sinceoptionalDuration like "5s", "2m", "3h"
sinceTimeoptionalRFC3339 timestamp
timestampsoptionalInclude timestamps in output
previousoptionalGet logs from previous container instance

Example:

json
{
  "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.

ParameterTypeDescription
contextoptionalKubernetes context name from kubeconfig (leave empty for current context)
namespaceoptionalTarget namespace (leave empty for all namespaces)
objectoptionalFilter by object name (e.g., pod name, deployment name)
eventTypeoptionalFilter by event type: "Normal" or "Warning" (case-insensitive)
reasonoptionalFilter by event reason (e.g., "Pulled", "Failed", "FailedScheduling")
sinceoptionalDuration like "5s", "2m", "1h"
sinceTimeoptionalRFC3339 timestamp (e.g., "2025-06-20T10:00:00Z")
limitoptionalMaximum number of events to return (default: 100)
timeoutSecondsoptionalRequest timeout (default: 30s)

Examples:

json
// 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
}

list_contexts

List all available Kubernetes contexts from your kubeconfig file.

Parameters: None - this tool takes no parameters.

Example Response:

json
{
  "contexts": [
    {
      "name": "production-cluster",
      "is_current": false
    },
    {
      "name": "staging-cluster", 
      "is_current": true
    },
    {
      "name": "development-cluster",
      "is_current": false
    }
  ],
  "current_context": "staging-cluster",
  "total": 3
}

Use Case: Perfect for multi-cluster workflows where you need to:

  • Discover available Kubernetes contexts
  • Identify the current active context
  • Plan operations across multiple clusters

🌟 Advanced Features

🌐 Multi-Cluster Support

Seamlessly work with multiple Kubernetes clusters using context switching:

  • Context Parameter: All tools now support an optional context parameter to specify which cluster to query
  • Automatic Discovery: Uses your existing kubeconfig file and automatically discovers available contexts
  • Default Context: When no context is specified, uses the current context from your kubeconfig
  • Cached Connections: Efficiently manages connections to multiple clusters with connection caching

Multi-cluster Examples:

json
// Query production cluster
{
  "kind": "Pod",
  "context": "production-cluster",
  "namespace": "default"
}

// Get logs from staging environment
{
  "name": "api-server",
  "context": "staging-cluster",
  "namespace": "api"
}

// Compare resources across environments (use multiple calls)
{
  "kind": "Deployment",
  "context": "production-cluster",
  "namespace": "app"
}

🎯 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:

FilterDiscoversExamples
"flux"FluxCD resourcesHelmReleases, Kustomizations, GitRepositories
"argo"ArgoCD resourcesApplications, AppProjects, ApplicationSets
"istio"Istio resourcesVirtualServices, DestinationRules, Gateways
"cert-manager"cert-manager resourcesCertificates, 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.

Cài đặt

TypingMind
{
  "mcpServers": {
    "kubernetes-mcp": {
      "command": "kubernetes-mcp",
      "args": []
    }
  }
}

Dùng MCP Kubernetes MCP 服务器 với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối Kubernetes MCP 服务器, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm Kubernetes MCP 服务器 làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của Kubernetes MCP 服务器.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "kubernetes-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của Kubernetes MCP 服务器, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của Kubernetes MCP 服务器.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng Kubernetes MCP 服务器 giúp tôi làm việc này không?
Kubernetes MCP 服务器
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng Kubernetes MCP 服务器.

Câu hỏi thường gặp

Máy chủ MCP Kubernetes MCP 服务器 dùng để làm gì?

Kubernetes MCP 服务器 là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP Kubernetes MCP 服务器 với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng Kubernetes MCP 服务器 với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP Kubernetes MCP 服务器 với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối Kubernetes MCP 服务器, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP Kubernetes MCP 服务器 với TypingMind?

Kubernetes MCP 服务器 hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP Kubernetes MCP 服务器 cung cấp những công cụ nào trong TypingMind?

Kubernetes MCP 服务器 cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP Kubernetes MCP 服务器 không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu Kubernetes MCP 服务器 yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇