k8s-mcp-server
K8s クラスタ運用 MCP Server
FastMCP ベースの Kubernetes 運用クエリ用 MCP サービス。kubectl get / describe / logs / events --watch などの日常的なトラブルシューティング操作を、LLM が呼び出せる読み取り専用ツールとしてカプセル化し、Claude などのクライアントが直接クラスタ状態を読み取り、障害の現場を特定できるようにします。
⚠️ 本プロジェクトは読み取り専用ツールのみを公開しています(create/update/delete なし)。ただし、後述の「セキュリティ推奨事項」に従い、読み取り専用 ServiceAccount の RBAC と組み合わせて使用することを推奨します。
ツール一覧
ツール | 説明 | 対応する kubectl |
| ノード一覧の概要 |
|
| ノード詳細 |
|
| ノードのリソース要求/制限の集計と過載評価 |
|
| 問題ノードのスキャン(NotReady / 各種 Pressure) | — |
| Pod 一覧(namespace / label / field フィルタ対応) |
|
| Pod 詳細(label / workload / 名称プレフィックスで特定) |
|
| Pod コンテナログの読み取り |
|
| イベントのクエリ(重複排除 + ソート) |
|
| イベントストリームのリアルタイム監視 |
|
| ノード状態変化のリアルタイム監視 |
|
| Pod 状態変化のリアルタイム監視 |
|
さらに、@mcp.prompt(ノード調査 / クラスタ巡回ガイド)と @mcp.resource(k8s://cluster/summary クラスタサマリー)の追加機能があります。
Related MCP server: Kubernetes MCP Server
ディレクトリ構造
├── app.py # FastMCP 实例(叶子模块,破循环导入)
├── k8s_server.py # 入口:导入 Tools 即自动注册全部工具
├── k8s_client.py # K8s 客户端懒加载 + 单一配置真源
├── config.py # 12-Factor 环境变量配置
├── prompts.py # @mcp.prompt 引导
├── resources.py # @mcp.resource 资源
├── Tools/ # 每个工具一个文件,导入即注册
├── utils/ # 纯解析/辅助模块(无 K8s/MCP 依赖)
└── tests/ # 单元测试インストールと実行
# 1. 创建虚拟环境并安装依赖
python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux / macOS
source .venv/bin/activate
pip install -r requirements.txt
# 2. 运行(HTTP transport,默认 127.0.0.1:8081)
python k8s_server.pyテストの実行
pip install -r requirements-dev.txt
python -m pytest -q設定
すべて環境変数で設定し、デフォルト値があります(config.py 参照):
変数 | デフォルト値 | 説明 |
|
| kubeconfig パスを明示指定。空の場合は公式の解決チェーン( |
|
| TLS 証明書を検証するかどうか。デバッグで自己署名かつリスクが明確な場合のみ |
|
| MCP サービス名 |
|
| トランスポート方式。 |
|
| リッスンアドレス |
|
| リッスンポート |
K8s 接続設定の読み込み優先順位: in-cluster(Pod 内の SA)→ 明示的な KUBECONFIG_PATH → 公式 kubeconfig 解決チェーン。単一の真実源であり、複数ファイルから合成しません。
MCP クライアントへの接続
Claude Code を例にします(HTTP トランスポートが 127.0.0.1:8081 で実行中の場合):
{
"mcpServers": {
"k8s-node-server": {
"url": "http://127.0.0.1:8081/mcp"
}
}
}セキュリティ推奨事項
読み取り専用 RBAC を使用:本サービスを実行する Pod / ユーザーには読み取り専用の ClusterRole を設定し、高権限の資格情報を借用しないようにします。
デフォルトでローカルのみにバインド:
MCP_HOSTはデフォルトで127.0.0.1。外部に公開する場合は、必ずリバースプロキシ層で認証(TLS + Token / OIDC)を追加してください。HTTP トランスポート自体には認証とレート制限がありません。証明書検証を無効にしない:
K8S_VERIFY_SSL=falseは自己署名証明書の一時的なデバッグのみに使用し、本番環境ではtrueのままにしてください。認証情報をリポジトリに入れない:kubeconfig には秘密鍵が含まれます。
.gitignoreでkubeconfig*を除外済みです。強制的にコミットしないでください。
既知の制限
すべてのツールは読み取り専用であり、変更操作は含まれません(これは意図的な設計です)。
watch_*シリーズはグローバルな排他ロックに制限されます。同時に実行できる watch は 1 つのみで、API Server への負荷を避けます。イベント / ログ出力には長さ上限があります。巨大な内容は切り詰められます(
read_pod_logの切り詰めロジックとquery_eventsのmax_countを参照)。
This 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
- AlicenseAqualityCmaintenanceProvides a set of read-only Kubernetes functions via an MCP server, enabling interaction with Kubernetes clusters through agents or coding assistants like GitHub Copilot.93Apache 2.0
- FlicenseNot gradedqualityDmaintenanceEnables real-time Kubernetes cluster observability and debugging through standardized MCP interface. Provides access to pods, services, nodes, events, and includes built-in tools for cluster health analysis and issue identification.
- FlicenseNot gradedqualityDmaintenanceEnables Kubernetes cluster introspection via MCP tools, such as listing pods, namespaces, nodes, and events.4
- AlicenseAqualityCmaintenanceA read-only MCP server for inspecting Kubernetes clusters, allowing LLMs to list resources, describe pods, and read logs without mutation.5MIT
Related MCP Connectors
Read-only Remote MCP for externally grounded AI agent trust receipts.
A paid remote MCP for AI SDK data query MCP, built to return verdicts, receipts, usage logs, and aud
AI Reasoning Cache & Consensus Layer with 11 MCP tools via Streamable HTTP.
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/zj-hub-coder/k8s-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server