mcp-server-kubernetes
MCP 服务器 Kubernetes
MCP 服务器可以连接到 Kubernetes 集群并对其进行管理。
https://github.com/user-attachments/assets/f25f8f4e-4d04-479b-9ae0-5dac452dd2ed
与 Claude Desktop 一起使用
{
"mcpServers": {
"kubernetes": {
"command": "npx",
"args": ["mcp-server-kubernetes"]
}
}
}服务器将自动连接到您当前的 kubectl 上下文。请确保您已:
kubectl 已安装并位于您的 PATH 中
已配置上下文的有效 kubeconfig 文件
访问为 kubectl 配置的 Kubernetes 集群(例如 minikube、Rancher Desktop、GKE 等)
已安装 Helm v3 并将其添加到您的 PATH 中(无需 Tiller)。如果您不打算使用 Helm,则此步骤可选。
您可以通过要求 Claude 列出您的 pod 或创建测试部署来验证您的连接。
如果出现错误,请打开标准终端并运行kubectl get pods以查看是否可以连接到集群而没有凭据问题。
Related MCP server: mcp-server-kubernetes
与 mcp-chat 一起使用
mcp-chat是 MCP 服务器的 CLI 聊天客户端。您可以使用它与 Kubernetes 服务器进行交互。
npx mcp-chat --server "npx mcp-server-kubernetes"或者,将您现有的 Claude Desktop 配置文件从上面传递给它(Linux 应该将正确的路径传递给配置):
苹果:
npx mcp-chat --config "~/Library/Application Support/Claude/claude_desktop_config.json"视窗:
npx mcp-chat --config "%APPDATA%\Claude\claude_desktop_config.json"特征
[x] 连接到 Kubernetes 集群
[x] 列出所有 pod、服务、部署
[x] 列出、描述节点
[x] 创建、描述、删除 Pod
[x] 列出所有命名空间,创建命名空间
[x] 创建自定义 pod 和部署配置,更新部署副本
[x] 创建、描述、删除、更新服务
[x] 创建、获取、更新、删除 ConfigMap
[x] 从 pod 获取日志以进行调试(支持 pod、部署、作业和标签选择器)
[x] 支持 Helm v3 安装图表
安装具有自定义值的图表
卸载版本
升级现有版本
支持命名空间
支持版本规范
支持自定义存储库
[x] kubectl explain 和 kubectl api-resources 支持
[x] 从集群获取 Kubernetes 事件
[x] 端口转发到 Pod 或服务
[x] 创建、列出和描述 cronjobs
[x] 用于读取和仅创建/更新集群访问的非破坏性模式
本地开发
确保已安装 bun 。克隆 repo 并安装依赖项:
git clone https://github.com/Flux159/mcp-server-kubernetes.git
cd mcp-server-kubernetes
bun install开发工作流程
以开发模式启动服务器(监视文件更改):
bun run dev运行单元测试:
bun run test构建项目:
bun run build使用Inspector进行本地测试
npx @modelcontextprotocol/inspector node dist/index.js
# Follow further instructions on terminal for Inspector link使用 Claude Desktop 进行本地测试
{
"mcpServers": {
"mcp-server-kubernetes": {
"command": "node",
"args": ["/path/to/your/mcp-server-kubernetes/dist/index.js"]
}
}
}使用mcp-chat进行本地测试
bun run chat贡献
有关详细信息,请参阅CONTRIBUTING.md文件。
先进的
其他高级功能
有关更多高级信息,例如使用 SSE 传输、带有ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS的非破坏性模式,请参阅ADVANCED_README.md 。
建筑学
请参阅此DeepWiki 链接,了解 Devin 创建的更深入的架构概述。
本节介绍 MCP Kubernetes 服务器的高层架构。
请求流程
下面的序列图说明了请求如何流经系统:
sequenceDiagram
participant Client
participant Transport as StdioTransport
participant Server as MCP Server
participant Handler as Request Handler
participant K8sManager as KubernetesManager
participant K8s as Kubernetes API
Client->>Transport: Send Request via STDIO
Transport->>Server: Forward Request
alt Tools Request
Server->>Handler: Route to tools handler
Handler->>K8sManager: Execute tool operation
K8sManager->>K8s: Make API call
K8s-->>K8sManager: Return result
K8sManager-->>Handler: Process response
Handler-->>Server: Return tool result
else Resource Request
Server->>Handler: Route to resource handler
Handler->>K8sManager: Get resource data
K8sManager->>K8s: Query API
K8s-->>K8sManager: Return data
K8sManager-->>Handler: Format response
Handler-->>Server: Return resource data
end
Server-->>Transport: Send Response
Transport-->>Client: Return Final Response发布新版本
前往发布页面,点击“草稿新版本”,点击“选择标签”,并使用“v{major}.{minor}.{patch}”语义版本格式输入新版本号,创建一个新标签。然后,输入发布标题“Release v{major}.{minor}.{patch}”,并根据需要添加描述/更新日志,然后点击“发布版本”。
这将创建一个新标签,并通过 cd.yml 工作流触发新的版本构建。成功后,新版本将发布到npm 。请注意,无需手动更新 package.json 版本,因为工作流会自动更新 package.json 文件中的版本号并将提交推送到主分支。
未计划
身份验证/向 kubectx 添加集群。
Available Tools
17 toolsexplain_resourceBRead-only
Get documentation for a Kubernetes resource or field
Inputs: resource (required), output, context, recursive, +1 more.
install_helm_chartBDestructive
Install a Helm chart with support for both standard and template-based installation
Inputs: name (required), chart (required), namespace (required), repo, +5 more.
kubectl_applyADestructive
Apply a Kubernetes YAML manifest from a string or file
Inputs: force, dryRun, context, filename, +2 more.
kubectl_contextBIdempotent
Manage Kubernetes contexts - list, get, or set the current context
Inputs: operation (required), name, output, detailed, +1 more.
kubectl_createB
Create Kubernetes resources using various methods (from file or using subcommands)
Inputs: name, port, image, dryRun, +19 more.
kubectl_describeARead-only
Describe Kubernetes resources by resource type, name, and optionally namespace
Inputs: name (required), resourceType (required), context, namespace, +1 more.
kubectl_getARead-only
Get or list Kubernetes resources by resource type, name, and optionally namespace
Inputs: resourceType (required), name, output, sortBy, +5 more.
kubectl_logsBRead-only
Get logs from Kubernetes resources like pods, deployments, or jobs
Inputs: name (required), namespace (required), resourceType (required), tail, +8 more.
kubectl_patchCDestructive
Update field(s) of a resource using strategic merge patch, JSON merge patch, or JSON patch
Inputs: name (required), resourceType (required), dryRun, context, +4 more.
kubectl_reconnectA
Reconnect to the Kubernetes API server by recreating all API clients. Use this after cluster upgrades (e.g., EKS control plane upgrades that rotate ENIs/IPs) to force fresh DNS resolution and new TCP connections.
Inputs: no named parameters.
kubectl_rolloutBDestructive
Manage the rollout of a resource (e.g., deployment, daemonset, statefulset)
Inputs: name (required), namespace (required), subCommand (required), resourceType (required), +5 more.
kubectl_scaleBDestructive
Scale a Kubernetes deployment
Inputs: name (required), replicas (required), context, namespace, +1 more.
list_api_resourcesCRead-only
List the API resources available in the cluster
Inputs: verbs, output, context, apiGroup, +1 more.
pingARead-only
Verify that the counterpart is still responsive and the connection is alive.
Inputs: no named parameters.
port_forwardC
Forward a local port to a port on a Kubernetes resource
Inputs: localPort (required), targetPort (required), resourceName (required), resourceType (required), +1 more.
stop_port_forwardD
Stop a port-forward process
Inputs: id (required).
upgrade_helm_chartCDestructive
Upgrade an existing Helm chart release
Inputs: name (required), chart (required), namespace (required), repo, +3 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 17 tools
Most tools target clearly distinct Kubernetes actions and resources, such as get vs describe, scale vs rollout, and port_forward vs stop_port_forward. The main overlap is kubectl_create vs kubectl_apply, since both can create or update resources from manifests, but their descriptions give enough guidance to distinguish typical use.
The set is readable and mostly uses snake_case action-oriented names, but the kubectl_ prefix is inconsistently applied across otherwise Kubernetes-related tools. For example, kubectl_get and kubectl_apply coexist with explain_resource, install_helm_chart, port_forward, and list_api_resources.
Seventeen tools is reasonable for a Kubernetes management server covering core resource, rollout, Helm, and connectivity workflows. A few tools like ping and kubectl_reconnect are auxiliary, but they support operational reliability rather than bloating the surface excessively.
The server covers create/apply, read, describe, patch, logs, scale, rollout, contexts, Helm install/upgrade, and port forwarding. However, there is no delete tool for Kubernetes resources, which is a notable lifecycle gap, and Helm coverage lacks list/uninstall operations.
Maintenance
Related MCP Connectors
Deploy and operate Kubernetes: clusters, stacks, apps, logs, metrics and security, with OAuth.
Deploy applications and manage governed Kubernetes preview spaces and capacity.
Manage Kubernetes clusters, deployments, databases, secrets and observability on Mengi Cloud.
Deploy and manage applications, databases and storage on Helm7.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI agents to interact with Kubernetes clusters through progressive disclosure, where agents discover TypeScript modules via filesystem, write and execute code, and receive summarized console output for cluster management tasks.27 npm2MIT
- AlicenseBqualityDmaintenanceEnables connection to a Kubernetes cluster to list and manage pods, services, deployments, and nodes, create/delete/describe pods, inspect namespaces, and retrieve logs for debugging.11MIT
- AlicenseBqualityDmaintenanceEnables connecting to a Kubernetes cluster to manage it, including listing pods, services, deployments, nodes, and namespaces, creating and deleting pods, describing pods, and retrieving logs for debugging.11MIT
- AlicenseBqualityDmaintenanceConnects to a Kubernetes cluster through the current kubectl context and enables listing, creating, deleting, and describing pods, services, deployments, nodes, and namespaces, plus retrieving logs for debugging.11MIT