Back to MCP directory
publicPublicdnsLocal runtime

mcp-kubernetes-server

mcp-kubernetes-server是一个MCP协议服务器,作为AI助手与Kubernetes集群之间的桥梁,通过自然语言交互实现Kubernetes操作。

article

README

🚀 MCP Kubernetes 服务器项目文档

MCP Kubernetes 服务器是一个用于与 Kubernetes 集群交互的工具,支持通过 MCP 协议进行通信。该项目旨在简化 Kubernetes 资源管理,并提供丰富的功能来操作集群中的工作负载和其他资源。

🚀 快速开始

📦 安装指南

安装命令行工具

pip install mcp-kubernetes-server

初始化配置

创建一个配置文件 k8s-config.yaml

apiVersion: v1
kind: MCPConfig
metadata:
  name: default
spec:
  kubernetes:
    server: http://localhost:6060 # 替换为你的 Kubernetes API 服务器地址
    inCluster: false
    namespace: default

启动 MCP 服务

uv run -m src.mcp_kubernetes_server.main

✨ 主要特性

资源操作工具

项目提供了多种工具来操作 Kubernetes 资源,包括:

  • 读取工具:用于获取资源信息。
  • 写入工具:用于创建、更新和删除资源。
  • 查询工具:用于搜索和筛选资源。

详细功能说明

读取工具

| 工具名称 | 描述 | 参数 | | ---- | ---- | ---- | | k8s_get | 获取单个资源 | resource_type, name, namespace | | k8s_list | 获取多个资源 | resource_type, label_selector, namespace | | k8s_watch | 实时监控资源变化 | resource_type, name, namespace |

写入工具

| 工具名称 | 描述 | 参数 | | ---- | ---- | ---- | | k8s_create | 创建新资源 | manifest_file | | k8s_apply | 应用配置文件到集群 | manifest_file, namespace | | k8s_replace | 更新现有资源 | patch_file, resource_type, name, namespace |

查询工具

| 工具名称 | 描述 | 参数 | | ---- | ---- | ---- | | k8s_search | 搜索符合条件的资源 | keyword, resource_type | | k8s_describe | 显示资源详细信息 | resource_type, name, namespace |

工具分类

读取工具(Read Tools)

| 工具名称 | 描述 | 参数 | | ---- | ---- | ---- | | k8s_get | 获取单个资源 | resource_type, name, namespace | | k8s_list | 获取多个资源 | resource_type, label_selector, namespace | | k8s_watch | 实时监控资源变化 | resource_type, name, namespace |

写入工具(Write Tools)

| 工具名称 | 描述 | 参数 | | ---- | ---- | ---- | | k8s_create | 创建新资源 | manifest_file | | k8s_apply | 应用配置文件到集群 | manifest_file, namespace | | k8s_replace | 更新现有资源 | patch_file, resource_type, name, namespace |

删除工具(Delete Tools)

| 工具名称 | 描述 | 参数 | | ---- | ---- | ---- | | k8s_delete | 删除指定资源 | resource_type, name, namespace |

📚 详细文档

开发指南

运行项目

uv run -m src.mcp_kubernetes_server.main

使用 Inspector 工具调试

# 启动 Inspector 工具进行调试
uv run --inspector http://localhost:6060 -m src.mcp_kubernetes_server.main

贡献指南

提交代码

  • 在 GitHub 上 fork 项目仓库。
  • 创建新的功能分支:git checkout -b feature/your-feature-name
  • 提交代码并推送至远程仓库:git push origin feature/your-feature-name
  • 提交 Pull Request 到主仓库。

问题反馈

  • 如果遇到问题,请在 GitHub 仓库的 Issues 部分提交问题。
  • 提供详细的错误信息和复现步骤,以便快速定位问题。

📄 许可证

项目采用 Apache 2.0 许可证,具体许可内容请参考 LICENSE 文件。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client