KubeSphere MCP 服务器

KubeSphere MCP Server 是一个与 KubeSphere API 集成的 MCP 服务器,用于从 KubeSphere 获取资源,适用于 Kubernetes 集群管理和扩展。

  • by kubesphere
  • Go
  • 本地部署
  • 17 星标
  • 更新于
在 GitHub 查看 kubesphere/ks-mcp-server

使用说明

KubeSphere MCP服务器

KubeSphere MCP服务器是 模型上下文协议(MCP) 提供与KubeSphere API集成的服务器,能够从KubeSphere获取资源。分为四个工具模块: Workspace Management, Cluster Management, User and Roles, Extensions Center.

先决条件

您必须拥有一个KubeSphere集群。包含:访问地址、用户名、密码。

安装

生成KSConfig

格式类似于kubeconfig。此配置包含HTTP连接器信息。KubeSphere的默认上下文为 kubesphere,可以通过环境变量进行修改 KUBESPHERE_CONTEXT.

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: <CA file>
    server: <Server Address>
  name: kubesphere
contexts:
- context:
    cluster: kubesphere
    user: admin
  name: kubesphere
current-context: kubesphere
kind: Config
preferences: {}
users:
- name: admin
  user:
    username: <KubeSphere Username>
    password: <KubeSphere Password>

<CA file>: 可选的通过HTTPS访问KubeSphere时,请以base64编码格式填写CA证书。
<Server Address>: 必需 必须是HTTPS地址。(如果使用HTTP,请在此处输入任何HTTPS地址,然后通过参数进行修改 --ks-apiserver http://xxx)
<KubeSphere Username>: 必需 KubeSphere集群的用户。
<KubeSphere Password>: 必需 KubeSphere集群用户的密码。

获取ks mcp服务器二进制文件

您可以运行命令 go build -o ks-mcp-server cmd/main.go 或从(github发布)下载[https://github.com/kubesphere/ks-mcp-server/releases] 然后将其移动到 $PATH.

在AI代理中配置MCP服务器

克劳德桌面

  1. 根据 克劳德桌面 应更改MCP配置。比如:
{
  "mcpServers": {
    "KubeSphere": {
      "args": [
        "stdio",
        "--ksconfig", "<ksconfig file absolute path>",
        "--ks-apiserver", "<KubeSphere Address>"
      ],
      "command": "ks-mcp-server"
    }
  }
}

<ksconfig file absolute path>: 必需 ksconfig文件的绝对路径。
<KubeSphere Address>: 可选(但HTTP访问需要) KubeSphere集群的访问地址,支持 ks-console 或 ks-apiserver 服务地址(例如。, http://172.10.0.1:30880).

  1. 与mcp服务器聊天

光标

  1. 根据 卷曲 应更改MCP配置。比如:
{
  "mcpServers": {
    "KubeSphere": {
      "args": [
        "stdio",
        "--ksconfig", "<ksconfig file absolute path>",
        "--ks-apiserver", "<KubeSphere Address>"
      ],
      "command": "ks-mcp-server"
    }
  }
}

<ksconfig file absolute path>: 必需 ksconfig文件的绝对路径。
<KubeSphere Address>: 可选(但HTTP访问需要) KubeSphere集群的访问地址,支持 ks-console 或 ks-apiserver 服务地址(例如。, http://172.10.0.1:30880).

  1. 与mcp服务器聊天