返回市场
MCP-K8S-Go

MCP-K8S-Go

作者:strowk363 星标更新:2025-11-18

项目介绍

<h4 align="center">基于Golang的MCP服务器连接到Kubernetes</h4> <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> ⚙ <a href="https://modelcontextprotocol.io">关于MCP ↗</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> <br/> <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="最新发布徽章"></a> <a href="https://goreportcard.com/report/github.com/strowk/mcp-k8s-go"><img src="https://goreportcard.com/badge/github.com/strowk/mcp-k8s-go" alt="Go参考"></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="许可证徽章"></a> </p>

特性

MCP 💬 提示 🗂️ 资源 🤖 工具

  • 🗂️🤖 列出Kubernetes上下文
  • 💬🤖 列出Kubernetes命名空间
  • 🤖 列出、获取、创建和修改任何Kubernetes资源
    • 包括自定义映射资源如Pods、Services、Deployments
  • 🤖 列出Kubernetes节点
  • 💬 列出Kubernetes Pods
  • 🤖 获取Kubernetes事件
  • 🤖 获取Kubernetes Pod日志
  • 🤖 在Kubernetes Pod中运行命令

使用Inspector浏览

要使用已发布的最新版本与Inspector一起使用,可以运行以下命令:

npx @modelcontextprotocol/inspector npx @strowk/mcp-k8s

与Claude一起使用

<details><summary><b> 演示用法 </b></summary>

以下与Claude Desktop的聊天演示了如何选择特定上下文作为资源,然后询问检查kube-system命名空间中的Pod日志是否有错误:

Claude Desktop

</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设置自动自动手动手动手动手动

使用Smithery

要通过Smithery自动安装MCP K8S Go用于Claude Desktop:

npx -y @smithery/cli install @strowk/mcp-k8s --client claude

使用mcp-get

要通过mcp-get自动安装MCP K8S Go用于Claude Desktop:

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": {
    "m[...]k8s_go": {
      "command": "mcp-k8s-go",
      "args": []
    }
  }
}

使用Docker

此服务器自0.3.1-beta.2版本起构建并发布到Docker Hub,支持多架构镜像,包括linux/amd64和linux/arm64架构。

您可以使用最新的标签,例如:

docker run -i -v ~/.kube/config:/home/nonroot/.kube/config --rm mcpk8s/server:latest

Windows用户可能需要将~/.kube/config替换为//c/Users/<username>/.kube/config至少在Git Bash中是这样。

对于Claude:

{
  "mcpServers": {
    "mcp_k8s_go": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "-v",
        "~/.kube/config:/home/nonroot/.kube/config",
        "--rm",
        "mcpk8s/server:latest"
      ]
    }
  }
}

环境变量和命令行选项

MCP服务器使用的环境变量如下:

  • KUBECONFIG:指向您的Kubernetes配置文件的路径(可选,默认为~/.kube/config)

支持的命令行选项如下:

  • --allowed-contexts=<ctx1,ctx2,...>:用户可以访问的允许的Kubernetes上下文的逗号分隔列表。如果没有指定,则允许所有上下文。
  • --readonly:禁用任何可以写入集群更改的工具
  • --help:显示帮助信息
  • --version:显示版本信息
  • --mask-secrets:在输出中屏蔽秘密(默认:true)。使用--mask-secrets=false以禁用屏蔽

例如,如果您正在配置Claude Desktop,可以在claude_desktop_config.json文件中添加以下配置:

{
    "mcpServers": {
        "mcp_k8s": {
            "command": "mcp-k8s",
            "args": [
                "--allowed-contexts=dev,prod",
                "--readonly"
            ]
        }
    }
}

, 这将仅允许使用devprod上下文,并禁用任何可以写入集群更改的工具。