Cover image
MCP-KUBERNETES服务器
Public

MCP-KUBERNETES服务器

Try Now
2025-04-07

轻巧的MCP服务器,可提供自然语言处理,并将API访问访问Kubernetes群集,并将Kubectl命令和Kubernetes Python客户端结合使用。

3 years

Works with Finder

1

Github Watches

0

Github Forks

0

Github Stars

Kubernetes MCP Server

Python Version License

A lightweight MCP server that provides natural language processing and API access to Kubernetes clusters, combining both kubectl commands and Kubernetes Python client.

https://github.com/user-attachments/assets/48e061cd-3e85-40ff-ab04-a1a2b9bbd152

✨ Features

  • Natural Language Interface: Convert plain English queries to kubectl commands
    • List pods and deployments across all namespaces
    • Fallback to general resource listing for unsupported queries
  • Full CRUD Operations:
    • 🆕 Create/Delete namespaces, pods, and deployments via API endpoints
    • 🔍 Inspect cluster resources
    • ✏️ Modify labels, annotations, and deployment configurations
    • 🗑️ Graceful deletion
    • 📊 Scale deployments
  • Dual Execution Mode:
    • kubectl command integration
    • Kubernetes Python client (official SDK)
  • Advanced Capabilities:
    • Namespace validation (DNS-1123 compliant)
    • Label filtering
    • Grace period control
    • Automatic command fallback
    • Resource management (CPU, memory)
    • Environment variable configuration

📦 Installation

Prerequisites

  • Python 3.11+
  • Kubernetes cluster access
  • kubectl configured locally
  • UV installed
# Clone repository
git clone https://github.com/ductnn/mcp-kubernetes-server.git 
cd mcp-kubernetes-server

# Create virtual environment
uv venv .venv

# Activate (Unix)
source .venv/bin/activate

# Install dependencies
uv pip install -r requirements.txt

🚀 Usage

Natural Language Processing

The server supports basic natural language queries for listing resources:

# List all pods
result = nl_processor.process("Show me all pods")

# List all deployments
result = nl_processor.process("Show me all deployments")

# Query with namespace
result = nl_processor.process("Show me all resources", "kube-system")

For more complex operations, use the dedicated API endpoints:

# Create a pod
pod_service.create_pod(
    name="my-pod",
    namespace="default",
    image="nginx:latest",
    labels={"app": "my-app"}
)

# Create a deployment
deployment_service.create_deployment(
    name="my-deployment",
    namespace="default",
    image="nginx:latest",
    replicas=3
)

# Delete a namespace
namespace_service.delete("my-namespace", force=True)

API Endpoints

The server provides RESTful endpoints for all operations:

  • /api/pods - Pod operations
  • /api/deployments - Deployment operations
  • /api/namespaces - Namespace operations
  • /api/cluster - Cluster operations
  • /api/nlp - Natural language processing

🤖 Usage with AI Assistants

Claude Desktop

  • Open your Claude Desktop and choose Settings -> choose mode Developer -> Edit config and open file claude_desktop_config.json and edit:
{
    "mcpServers": {
        "kubernetes": {
            "command": "/path-to-your-uv/uv",
            "args": [
                "--directory",
                "/path-you-project/", // Example for me /Users/ductn/mcp-kubernetes-server
                "run",
                "main.py"
            ]
        }
    }
}
  • Then, restart your Claude Desktop and play :)

🧪 Testing

Run the test suite:

# Run all tests
pytest

# Run specific test file
pytest tests/unit/test_pod_service.py

# Run with coverage
pytest --cov=.

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Lists Tailwind CSS classes in monospaced font

  • tomoyoshi hirata
  • Sony α7IIIマニュアルアシスタント

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • HiveNexus
  • 一个适用于中小型团队的AI聊天机器人,支持DeepSeek,Open AI,Claude和Gemini等车型。 专为中小团队设计的ai聊天应用,支持deepSeek,打开ai,claude,双子座等模型。

  • ravitemer
  • 一个功能强大的Neovim插件,用于管理MCP(模型上下文协议)服务器

  • patruff
  • Ollama和MCP服务器之间的桥梁,使本地LLMS可以使用模型上下文协议工具

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • JackKuo666
  • 🔍使AI助手可以通过简单的MCP接口搜索和访问PYPI软件包信息。

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

    Reviews

    1 (1)
    Avatar
    user_9DbNm9N5
    2025-04-17

    As a dedicated user of the mcp-kubernetes-server by ductnn, I must say it has significantly streamlined our container orchestration. Its seamless integration and user-friendly interface make managing Kubernetes clusters a breeze. Highly recommend this to anyone looking for an efficient Kubernetes server solution.