Back to MCP directory
publicPublicdnsLocal runtime

harvester-mcp-server

Harvester MCP Server是一个基于Go语言实现的MCP协议服务器,专为Harvester HCI设计,使AI助手能够通过自然语言与Harvester集群交互。

article

README

🚀 Harvester MCP 服务器

Harvester MCP 服务器是 Harvester HCI 的 Model Context Protocol (MCP) 服务器,它让 Claude Desktop、Cursor 等 AI 助手能通过 MCP 协议与 Harvester 集群进行交互,为用户操作 Harvester 集群提供了便利。

🚀 快速开始

Harvester MCP Server 是 Model Context Protocol (MCP) 的 Go 实现,专为 Harvester HCI 量身打造。它能让 Claude Desktop 和 Cursor 这类 AI 助手对 Harvester 集群执行 CRUD 操作,而这些集群本质上是带有 Harvester 特定 CRD 的 Kubernetes 集群。

下图展示了 Harvester MCP Server 如何架起人工智能助手与 Harvester 集群之间的桥梁:

graph LR;
    subgraph "AI 助手"
        A[Claude Desktop] --> C[MCP 客户端];
        B[Cursor IDE] --> C;
    end
    
    subgraph "MCP 服务器"
        C --> D[Harvester MCP Server];
    end
    
    subgraph "Kubernetes 集群"
        D --> E[Kubernetes API Server];
    end

✨ 主要特性

  • Harvester MCP 服务器 基于 Go 实现,允许 AI 助手如 Claude Desktop 和 Cursor 通过 MCP 协议与 Harvester 集群交互。
  • 支持用户对带有 Harvester 特定 CRD 的 Kubernetes 集群执行 CRUD 操作。

📦 安装指南

安装步骤

  1. 克隆仓库
git clone https://github.com/your-repository/harvester-mcp-server.git
cd harvester-mcp-server
  1. 安装依赖项:使用 Go 模块管理依赖。
go mod tidy
  1. 构建二进制文件
go build -o bin/harvester-mcp-server ./cmd/harvester-mcp-server/

配置 MCP 服务器

  1. 环境变量配置
    • 设置 Kubernetes 配置文件路径:
export KUBECONFIG=/path/to/your/kubeconfig.yaml
  • 设置日志级别(可选):
export LOG_LEVEL=info
  1. 启动服务器
./bin/harvester-mcp-server --kubeconfig /path/to/kubeconfig.yaml --log-level info

💻 使用示例

基础用法

与 Claude Desktop 配合使用

  1. 编辑配置文件:打开 ~/Library/Application\ Support/Claude/claude_desktop_config.json,添加 Harvester MCP 服务器到 mcpServers 中。
{
  "mcpServers": {
    "harvester": {
      "command": "/path/to/harvester-mcp-server",
      "args": ["--kubeconfig", "/path/to/kubeconfig.yaml", "--log-level", "info"]
    }
  }
}
  1. 重启 Claude Desktop:完成配置后,重启 Claude Desktop 以应用更改。
  2. 使用 MCP 功能:现在可以在 Claude Desktop 中使用 Harvester MCP 功能了。

示例查询

  • "我的 Harvester 集群中有多少节点?"
  • "列出 cattle-system 命名空间中的所有 pods。"
  • "显示 cattle-system 命名空间中名为 rancher-789c976c6-xbvmd 的 pod 详情。"
  • "列出默认命名空间中的所有虚拟机。"
  • "harvester-system 命名空间中有哪些服务在运行?"

🔧 技术细节

项目结构

cmd/harvester-mcp-server/
pkg/

添加新功能

  1. 新增资源类型:在 pkg/kubernetes/types.go 中添加新的资源类型。
  2. 实现格式化器:在相应的格式化文件中为新资源实现格式化器。
  3. 注册工具:在 pkg/mcp/server.goregisterTools 方法中使用统一的资源处理程序注册新工具。

📄 许可证

此项目根据 Apache License 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