KubeSphere MCP 服务器是一个模型上下文协议(MCP)服务器,提供与 KubeSphere API 的集成,使用户能够从 KubeSphere 获取资源。该服务器分为四个工具模块:工作区管理,集群管理,用户和角色,扩展中心。
您必须拥有一个 KubeSphere 集群。包括:访问地址、用户名、密码。
格式类似于 kubeconfig。此配置包含 HTTP 连接器信息。KubeSphere 的默认上下文是 kubesphere,可以通过环境变量 KUBESPHERE_CONTEXT 进行修改。
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: <CA 文件>
server: <服务器地址>
name: kubesphere
contexts:
- context:
cluster: kubesphere
user: admin
name: kubesphere
current-context: kubesphere
kind: Config
preferences: {}
users:
- name: admin
user:
username: <KubeSphere 用户名>
password: <KubeSphere 密码>
<CA 文件>: 可选。当通过 HTTPS 访问 KubeSphere 时,需要填写 base64 编码格式的 CA 证书。
<服务器地址>: 必需 必须是一个 HTTPS 地址。(如果使用 HTTP,请在此处输入任意 HTTPS 地址,然后通过参数 --ks-apiserver http://xxx 进行修改)
<KubeSphere 用户名>: 必需 KubeSphere 集群的用户。
<KubeSphere 密码>: 必需 KubeSphere 集群用户的密码。
您可以运行命令 go build -o ks-mcp-server cmd/main.go 或从 GitHub 发布页面下载,并将其移动到 $PATH。
{
"mcpServers": {
"KubeSphere": {
"args": [
"stdio",
"--ksconfig", "<ksconfig 文件绝对路径>",
"--ks-apiserver", "<KubeSphere 地址>"
],
"command": "ks-mcp-server"
}
}
}
<ksconfig 文件绝对路径>: 必需 ksconfig 文件的绝对路径。
<KubeSphere 地址>: 可选(但 HTTP 访问时必需) KubeSphere 集群的访问地址,支持 ks-console 或 ks-apiserver 服务地址(例如:http://172.10.0.1:30880)。

{
"mcpServers": {
"KubeSphere": {
"args": [
"stdio",
"--ksconfig", "<ksconfig 文件绝对路径>",
"--ks-apiserver", "<KubeSphere 地址>"
],
"command": "ks-mcp-server"
}
}
}
<ksconfig 文件绝对路径>: 必需 ksconfig 文件的绝对路径。
<KubeSphere 地址>: 可选(但 HTTP 访问时必需) KubeSphere 集群的访问地址,支持 ks-console 或 s-apiserver 服务地址(例如:http://172.10.0.1:30880)。
