mcp-k8s-go
这个项目旨在成为一个连接到 Kubernetes 的 MCP 服务器,同时也是一个用于为 Kubernetes 中任何自定义资源构建更多服务器的库。
README
基于 Golang 的 MCP 服务器连接到 Kubernetes
<h1 align="center"> <img src="docs/images/logo.png" width="180"/> <br/> MCP K8S Go </h1>
<p align="center"> <a href="#features">特性</a> ⚙ <a href="#browse-with-inspector">使用 Inspector 浏览</a> ⚙ <a href="#use-with-claude">与 Claude 一起使用</a> ⚙ <a href="https://github.com/strowk/mcp-k8s-go/blob/main/CONTRIBUTING.md">贡献 ↗</a> </p>
<p align="center"> <a href="https://github.com/strowk/mcp-k8s-go/actions/workflows/dependabot/dependabot-updates"><img src="https://github.com/strowk/mcp-k8s-go/actions/workflows/dependabot/dependabot-updates/badge.svg"></a> <a href="https://github.com/strowk/mcp-k8s-go/actions/workflows/test.yaml"><img src="https://github.com/strowk/mcp-k8s-go/actions/workflows/test.yaml/badge.svg"></a> <a href="https://github.com/strowk/mcp-k8s-go/actions/workflows/golangci-lint.yaml"><img src="https://github.com/strowk/mcp-k8s-go/actions/workflows/golangci-lint.yaml/badge.svg"/></a> <a href="https://github.com/strowk/mcp-k8s-go/releases/latest"><img src="https://img.shields.io/github/v/release/strowk/mcp-k8s-go?logo=github&color=22ff22" alt="latest release badeg"></a> <a href="https://www.npmjs.com/package/@strowk/mcp-k8s"><img src="https://img.shields.io/npm/dw/@strowk/mcp-k8s?label=NPM downloads" alt="npm downloads badge"></a> <a href="https://github.com/strowk/mcp-k8s-go/blob/main/LICENSE"><img src="https://img.shields.io/github/license/strowk/mcp-k8s-go" alt="license badge"></a> </p>
特性
MCP 💬 提示 🗂️ 资源 🤖 工具
- 🗂️🤖 列出 Kubernetes 上下文
- 💬🤖 列出 Kubernetes 命名空间
- 🤖 列出和获取任何 Kubernetes 资源
- 包括对 Pod、Service、Deployment 等资源的自定义映射,但可以列出和检索任何资源
- 🤖 列出 Kubernetes 节点
- 💬 列出 Kubernetes Pod
- 🤖 获取 Kubernetes 事件
- 🤖 获取 Kubernetes Pod 日志
- 🤖 在 Kubernetes Pod 中运行命令
使用 Inspector 浏览
要使用 Inspector 浏览最新发布的版本,您可以运行以下命令:
npx @modelcontextprotocol/inspector npx @strowk/mcp-k8s
或者,要使用从源代码构建的版本,请在此项目的根文件夹中执行:
tools/inspector/run.sh
与 Claude 一起使用
<details><summary><b> 演示用法 </b></summary>
以下与 Claude Desktop 的聊天演示了选择特定上下文作为资源,然后要求检查 kube-system 命名空间中 Pod 日志中的错误时的外观:
</details>
要将此 MCP 服务器与 Claude Desktop(或任何其他客户端)一起使用,您可能需要选择要使用的安装方式。
您有多个选项:
<a href="#using-smithery">Smithery</a> | <a href="#using-mcp-get">mcp-get</a> | <a href="#prebuilt-from-npm">预构建 NPM</a> | <a href="#from-github-releases">GitHub 预构建</a> | <a href="#building-from-source">从源代码构建</a> | <a href="#using-docker">使用 Docker</a> | |
---|---|---|---|---|---|---|
Claude 设置 | 自动 | 自动 | 手动 | 手动 | 手动 | 手动 |
前提条件 | Node.js | Node.js | Node.js | 无 | Golang | Docker |
使用 Smithery
要通过 Smithery 为 Claude Desktop 自动安装 MCP K8S Go:
npx -y @smithery/cli install @strowk/mcp-k8s --client claude
使用 mcp-get
要通过 mcp-get 为 Claude Desktop 自动安装 MCP K8S Go:
npx @michaellatman/mcp-get@latest install @strowk/mcp-k8s
手动使用预构建的二进制文件
预构建 NPM
如果您已安装 npm 并且想要使用预构建的二进制文件,请使用此方法:
npm install -g @strowk/mcp-k8s
然后通过运行 mcp-k8s --version
检查版本,如果输出了已安装的版本,您可以继续将配置添加到 claude_desktop_config.json
文件:
{
"mcpServers": {
"mcp_k8s": {
"command": "mcp-k8s",
"args": []
}
}
}
或者使用 npx
与任何客户端:
npx @strowk/mcp-k8s
例如,对于 Claude:
{
"mcpServers": {
"mcp_k8s": {
"command": "npx",
"args": [
"@strowk/mcp-k8s"
]
}
}
}
从 GitHub 发布
前往 GitHub 发布 并下载适用于您平台的最新版本。
解压缩存档,其中包含名为 mcp-k8s-go
的二进制文件,将该二进制文件放在 PATH 中的某个位置,然后将以下配置添加到 claude_desktop_config.json
文件:
{
"mcpServers": {
"mcp_k8s": {
"command": "mcp-k8s-go",
"args": []
}
}
}
从源代码构建
您需要安装 Golang 才能构建此项目:
go get github.com/strowk/mcp-k8s-go
go install github.com/strowk/mcp-k8s-go
然后将以下配置添加到 claude_desktop_config.json
文件:
{
"mcpServers": {
"mcp_k8s_go": {
"command": "mcp-k8s-go",
"args": []
}
}
}
使用 Docker
自 0.3.1-beta.2 版本以来,此服务器已构建并发布到 Docker Hub,并提供适用于 linux/amd64 和 linux/arm64 架构的多架构镜像。
您可以像这样使用 latest 标签,例如:
docker run -i -v ~/.kube/config:/root/.kube/config --rm mcpk8s/server:latest
Windows 用户可能需要在 Git Bash 中将 ~/.kube/config
替换为 C:/Users/<username>/.kube/config
。
对于 Claude:
{
"mcpServers": {
"mcp_k8s_go": {
"command": "docker",
"args": [
"run",
"-i",
"-v",
"~/.kube/config:/root/.kube/config",
"--rm",
"mcpk8s/server:latest"
]
}
}
}
环境变量和命令行选项
MCP 服务器使用以下环境变量:
KUBECONFIG
: Kubernetes 配置文件的路径(可选,默认为 ~/.kube/config)
支持以下命令行选项:
--allowed-contexts=<ctx1,ctx2,...>
: 允许用户访问的 Kubernetes 上下文的逗号分隔列表。 如果未指定,则允许所有上下文。--help
: 显示帮助信息--version
: 显示版本信息
推荐服务器
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Excel MCP Server
一个模型上下文协议服务器,使 AI 助手能够读取和写入 Microsoft Excel 文件,支持诸如 xlsx、xlsm、xltx 和 xltm 等格式。
Playwright MCP Server
提供一个利用模型上下文协议的服务器,以实现类人浏览器的自动化,该服务器使用 Playwright,允许控制浏览器行为,例如导航、元素交互和滚动。
Claude Code MCP
一个实现了 Claude Code 作为模型上下文协议(Model Context Protocol, MCP)服务器的方案,它可以通过标准化的 MCP 接口来使用 Claude 的软件工程能力(代码生成、编辑、审查和文件操作)。
Apple MCP Server
通过 MCP 协议与 Apple 应用(如“信息”、“备忘录”和“通讯录”)进行交互,从而使用自然语言发送消息、搜索和打开应用内容。
contentful-mcp
在你的 Contentful Space 中更新、创建、删除内容、内容模型和资源。

Supabase MCP Server
一个模型上下文协议(MCP)服务器,它提供对 Supabase 管理 API 的编程访问。该服务器允许 AI 模型和其他客户端通过标准化的接口来管理 Supabase 项目和组织。

Azure MCP Server
通过 Claude Desktop 实现与 Azure 服务的自然语言交互,支持资源管理、订阅处理和租户选择,并提供安全身份验证。

Settlemint
利用 SettleMint 的模型上下文协议服务器,无缝地与企业区块链基础设施交互。通过人工智能驱动的助手构建、部署和管理智能合约,从而简化您的区块链开发工作流程,实现最高的效率。

Brev
在云端运行、构建、训练和部署机器学习模型。