Skip to main content
Glama
mcp-server-kubernetes
by Flux159

MCP サーバー Kubernetes

CI 言語 パン Kubernetes ドッカー 星 問題 PR歓迎 最終コミット 鍛冶屋のバッジ

Kubernetes クラスターに接続して管理できる MCP サーバー。

https://github.com/user-attachments/assets/f25f8f4e-4d04-479b-9ae0-5dac452dd2ed

Claude Desktopでの使用

{
  "mcpServers": {
    "kubernetes": {
      "command": "npx",
      "args": ["mcp-server-kubernetes"]
    }
  }
}

サーバーは現在のkubectlコンテキストに自動的に接続します。以下の点に注意してください。

  1. kubectl がインストールされ、PATH に含まれている

  2. コンテキストが設定された有効なkubeconfigファイル

  3. kubectl 用に構成された Kubernetes クラスターへのアクセス (例: minikube、Rancher Desktop、GKE など)

  4. Helm v3がインストールされ、PATHに設定されている(Tillerは不要)。Helmを使用しない場合はオプションです。

Claude にポッドの一覧を表示するかテスト デプロイメントを作成するように依頼することで、接続を確認できます。

エラーが発生した場合は、標準ターミナルを開いて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 は正しいパスを config に渡す必要があります)。

マック:

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] すべてのポッド、サービス、デプロイメントを一覧表示する

  • [x] ノードの一覧表示、説明

  • [x] ポッドの作成、説明、削除

  • [x] すべての名前空間を一覧表示し、名前空間を作成する

  • [x] カスタムポッドとデプロイメント構成を作成し、デプロイメントレプリカを更新する

  • [x] サービスの作成、説明、削除、更新

  • [x] ConfigMapの作成、取得、更新、削除

  • [x] デバッグのためにポッドからログを取得する(ポッド、デプロイメント、ジョブ、ラベルセレクターをサポート)

  • [x] チャートのインストールにHelm v3をサポート

    • カスタム値でチャートをインストールする

    • アンインストールリリース

    • 既存のリリースをアップグレードする

    • 名前空間のサポート

    • バージョン指定のサポート

    • カスタムリポジトリのサポート

  • [x] kubectl explain と kubectl api-resources のサポート

  • [x] クラスターからKubernetesイベントを取得する

  • [x] ポッドまたはサービスへのポート転送

  • [x] cronジョブの作成、一覧表示、および説明

  • [x] クラスタへの読み取りおよび作成/更新専用アクセスのための非破壊モード

地域開発

bun がインストールされていることを確認してください。リポジトリをクローンして依存関係をインストールします。

git clone https://github.com/Flux159/mcp-server-kubernetes.git
cd mcp-server-kubernetes
bun install

開発ワークフロー

  1. 開発モードでサーバーを起動します(ファイルの変更を監視します)。

bun run dev
  1. ユニットテストを実行します。

bun run test
  1. プロジェクトをビルドします。

bun run build
  1. Inspectorを使用したローカルテスト

npx @modelcontextprotocol/inspector node dist/index.js
# Follow further instructions on terminal for Inspector link
  1. Claude Desktopを使用したローカルテスト

{
  "mcpServers": {
    "mcp-server-kubernetes": {
      "command": "node",
      "args": ["/path/to/your/mcp-server-kubernetes/dist/index.js"]
    }
  }
}
  1. mcp-chatを使用したローカルテスト

bun run chat

貢献

詳細については、 CONTRIBUTING.mdファイルを参照してください。

高度な

追加の高度な機能

SSE トランスポートの使用、 ALLOW_ONLY_NON_DESTRUCTIVE_TOOLSによる非破壊モードなどのより高度な情報については、 ADVANCED_README.md を参照してください。

建築

Devin が作成したより詳細なアーキテクチャの概要については、このDeepWiki リンクを参照してください。

このセクションでは、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 ファイルのバージョン番号が自動的に更新され、main にコミットがプッシュされるため、package.json のバージョンを手動で更新する必要はありません。

計画なし

認証/kubectx へのクラスターの追加。

Available Tools

17 tools
explain_resourceB
Read-only

Get documentation for a Kubernetes resource or field

Inputs: resource (required), output, context, recursive, +1 more.

install_helm_chartB
Destructive

Install a Helm chart with support for both standard and template-based installation

Inputs: name (required), chart (required), namespace (required), repo, +5 more.

kubectl_applyA
Destructive

Apply a Kubernetes YAML manifest from a string or file

Inputs: force, dryRun, context, filename, +2 more.

kubectl_contextB
Idempotent

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_describeA
Read-only

Describe Kubernetes resources by resource type, name, and optionally namespace

Inputs: name (required), resourceType (required), context, namespace, +1 more.

kubectl_getA
Read-only

Get or list Kubernetes resources by resource type, name, and optionally namespace

Inputs: resourceType (required), name, output, sortBy, +5 more.

kubectl_logsB
Read-only

Get logs from Kubernetes resources like pods, deployments, or jobs

Inputs: name (required), namespace (required), resourceType (required), tail, +8 more.

kubectl_patchC
Destructive

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_rolloutB
Destructive

Manage the rollout of a resource (e.g., deployment, daemonset, statefulset)

Inputs: name (required), namespace (required), subCommand (required), resourceType (required), +5 more.

kubectl_scaleB
Destructive

Scale a Kubernetes deployment

Inputs: name (required), replicas (required), context, namespace, +1 more.

list_api_resourcesC
Read-only

List the API resources available in the cluster

Inputs: verbs, output, context, apiGroup, +1 more.

pingA
Read-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_chartC
Destructive

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

    C2.9/5.0

    Scored across 17 tools

    Disambiguation4/5

    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.

    Naming Consistency3/5

    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.

    Tool Count4/5

    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.

    Completeness3/5

    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

    ActivityActive
    ResponsivenessUsually handled

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables 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.
      2
      7 npm
      2
      MIT