mcp-kubernetes
mcp-kubernetes
一个适用于 Kubernetes 的 Model Context Protocol 服务器。它让支持 MCP 的客户端(Claude Desktop、Claude Code 等)能够跨多个上下文(context)查看并操作 Kubernetes 集群,行为完全由标志(flag)控制。
设计目标是默认安全(safe by default):默认以只读(read-only)模式启动,可以通过命名空间和上下文的允许列表(allowlist)限制范围,保护系统命名空间不被修改,并将危险操作(delete、apply、exec)置于显式 opt-in 门槛之后。
功能
多集群 — 每个工具都接受一个可选的
context参数;可通过允许列表指定可用的上下文。访问模式 —
read-only→read-write→admin逐层递进,任何模式都不会暴露其级别之上的工具。安全标志 — 命名空间允许列表、受保护命名空间、上下文允许列表,此外还有针对 delete / apply / exec 的独立 opt-in,以及 dry-run 和 JSON 审计日志(见下文)。
标准认证 — 使用你的 kubeconfig(或集群内 service account),服务器不会存储任何凭据。
Related MCP server: k8s-mcp-go
安全模型
关注点 | 标志(Flag) | 默认值 | 效果 |
服务器到底能做什么? |
|
|
|
哪些命名空间在范围内? |
| (全部) | 设置后,对列表之外命名空间执行的任何操作都会被拒绝。 |
哪些命名空间永远只读? |
|
| 可以读取,但无论处于什么模式,都不能修改或删除。 |
哪些集群可达? |
| (全部) | 设置后,只有这些 kube-config 上下文可以被访问。 |
能否删除资源? |
|
|
|
能否 apply 清单(manifest)? |
|
|
|
能否在 Pod 中执行命令(exec)? |
|
|
|
不触碰集群的情况下预览 |
|
| 写入/管理工具会先校验并记录操作意图,然后直接返回,不实际调用 API。 |
审计跟踪 |
|
| 每次受保护操作都会向 stderr 输出一行 JSON( |
安全层级彼此独立——例如,三个 opt-in 全部为 false 的 admin 模式下,可以实现 Deployment 重启和扩缩容,但不能删除了也不能执行 delete 或 exec。
工具
读取(read-only+):list_contexts、list_namespaces、list_pods、get_pod、get_pod_logs、list_deployments、list_services、list_nodes、list_events、get_resource
写入(read-write+):scale_deployment、restart_deployment、set_deployment_image、create_namespace、apply_manifest(需要 K8S_ALLOW_APPLY)
管理(admin):delete_resource(需要 K8S_ALLOW_DELETE)、exec_in_pod(需要 K8S_ALLOW_EXEC)
与你的 MCP 客户端搭配使用
支持 Claude Code、Claude Desktop、Cursor、OpenAI Codex CLI、Windsurf、VS Code(Copilot)以及任何其他 MCP 客户端——各客户端的配置方式请参阅 docs/CLIENTS.md。
安装
npm install
npm run build使用 Claude Desktop / Claude Code 运行
将其添加到你的 MCP 客户端配置:
{
"mcpServers": {
"kubernetes": {
"command": "node",
"args": ["/absolute/path/to/mcp-kubernetes/dist/index.js"],
"env": {
"KUBECONFIG_PATH": "/Users/you/.kube/config",
"K8S_MODE": "read-only",
"K8S_CONTEXT_ALLOWLIST": "staging",
"K8S_NAMESPACE_ALLOWLIST": "app,web"
}
}
}
}如需扩缩容或重启,则将 K8S_MODE 调整为 read-write;只有当你确实想要允许删除或 exec 时,才将其调整为 admin(并设置相应的 K8S_ALLOW_* 标志)。
开发
npm run dev # watch mode
npm test # unit tests for the security policy
npm run typecheck发布
该服务器提供了一份用于官方 MCP 注册表的 server.json,以及用于 npm 所有权验证的 mcpName。有关发布到 npm 以及在 MCP registry、Smithery、Glama、Cursor 和 PulseMCP 上架的说明,请参阅 PUBLISHING.md。
许可证
MIT
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn MCP server that enables interaction with multiple Kubernetes clusters simultaneously, providing comprehensive tools for cluster management, resource operations, and diagnostics across different environments.
- AlicenseNot gradedqualityAmaintenanceSafe, read-only-by-default Kubernetes access for AI agents via MCP. Provides explicit readonly, readwrite, and dangerous permission modes, plus MCPB bundles for desktop clients.2MIT
- FlicenseNot gradedqualityDmaintenanceEnables Kubernetes cluster introspection via MCP tools, such as listing pods, namespaces, nodes, and events.4
- AlicenseNot gradedqualityCmaintenanceAn MCP server for generating Kubernetes manifests (deployments, services, configmaps, secrets, ingresses, namespaces) and performing kubectl operations like apply, delete, get, describe, logs, and exec.MIT
Related MCP Connectors
Managed Keycloak from any MCP client: clusters, realms, apps, SSO, users, domains, audit events.
Remote MCP for A2A caller identity, scope policy, verdict receipts, and audit history.
Remote MCP for Copilot CLI switch gate MCP, structured receipts, audit logs, and reviewer-ready evid
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/dockndevai/mcp-kubernetes'
If you have feedback or need assistance with the MCP directory API, please join our Discord server