k8s-mcp-server
Supports connecting to and managing K3s clusters (both local and cloud) for the same Kubernetes operations, such as listing pods, nodes, namespaces, events, and fetching logs.
Provides tools for querying and troubleshooting Kubernetes clusters, including listing namespaces, pods, nodes, and events, describing pods, and retrieving pod logs.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@k8s-mcp-serverlist pods in the kube-system namespace"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
k8s-mcp-server
一个基于 MCP(Model Context Protocol) 的 Kubernetes 运维助手。它将 K8s 集群的查询能力封装成标准化的 MCP 工具,让 LLM 客户端(如 ZCode、Claude Desktop、Cursor)能够通过自然语言查看和排查 Kubernetes 集群。
功能特性
基于 MCP Python SDK,使用 stdio 传输
支持多集群切换(本地 k3s / 阿里云 k3s)
完善的异常处理,错误信息对 LLM 友好
输出经过精简格式化,避免返回冗余的 K8s 原始对象
Related MCP server: Multi Cluster Kubernetes MCP Server
工具列表
工具 | 说明 |
| 健康检查,返回 pong |
| 列出所有 namespace 及其状态 |
| 列出指定 namespace 下的 Pod |
| 查看 Pod 详情(状态、IP、节点、容器、重启次数、资源) |
| 获取 Pod 日志(支持 tail_lines 限制行数) |
| 列出集群节点及状态、OS、K8s 版本 |
| 列出所有 namespace 的最近事件(按时间倒序) |
环境要求
Python 3.12+
uv 包管理器
可访问的 Kubernetes 集群及对应的 kubeconfig
安装
git clone git@github.com:AmazingYe-oss/k8s-mcp-server.git
cd k8s-mcp-server
uv sync配置
默认从以下路径加载 kubeconfig(在 src/k8s_mcp_server/k8s_client.py 中配置):
local→~/.kube/configcloud→~/.kube/config-k3s-cloud
如需修改集群映射,编辑 KUBECONFIGS 字典即可。
运行
uv run k8s-mcp-server服务器以 stdio 模式启动,等待 MCP 客户端连接。
MCP 客户端配置
ZCode / Claude Desktop(Windows 连接 WSL 中的 Server)
{
"mcp": {
"servers": {
"k8s": {
"type": "stdio",
"command": "wsl",
"args": [
"bash",
"-lc",
"cd /home/<your-user>/k8s-mcp-server && uv run k8s-mcp-server"
]
}
}
}
}原生 Linux/macOS
{
"mcp": {
"servers": {
"k8s": {
"type": "stdio",
"command": "uv",
"args": ["--directory", "/path/to/k8s-mcp-server", "run", "k8s-mcp-server"]
}
}
}
}项目结构
src/k8s_mcp_server/
├── __init__.py
├── server.py # MCP Server 入口,注册工具
├── k8s_client.py # K8s API 客户端封装与异常处理
└── formatters.py # K8s 对象到精简文本的格式化开发
# 代码检查
uv run ruff check .
# 运行测试
uv run pytestThis server cannot be installed
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
- Alicense-qualityDmaintenanceA read-only MCP server for Kubernetes that allows querying cluster information and diagnosing issues through natural language interfaces like Claude.8MIT
- Flicense-qualityDmaintenanceAn MCP server that enables interaction with multiple Kubernetes clusters simultaneously, providing comprehensive tools for cluster management, resource operations, and diagnostics across different environments.
- Alicense-qualityDmaintenanceAn MCP server that enables AI assistants to interact with Kubernetes clusters by translating natural language into kubectl and Helm operations. It allows users to query, manage, and diagnose Kubernetes resources and cluster states through a seamless integration.20Apache 2.0
- Alicense-qualityCmaintenanceA lightweight MCP server that enables natural language interaction with Kubernetes clusters, allowing management of pods, deployments, namespaces, and cluster resources through conversational queries or API endpoints.1MIT
Related MCP Connectors
Official Microsoft MCP Server to query Microsoft Entra data using natural language
GibsonAI MCP server: manage your databases with natural language
MCP server for AI dialogue using various LLM models via AceDataCloud
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/AmazingYe-oss/k8s-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server