MCP.so
ログイン
K

K8s MCP Server

@christian-schlichtherle

基本情報

カテゴリ

クラウドとインフラ

トランスポート

stdio

作者

christian-schlichtherle

投稿者

Christian Schlichtherle

K8s MCP Server について

An MCP server for comprehensive access to one or more Kubernetes clusters

K8s MCP Server の設定

以下の設定を使って、このサーバーを MCP 対応クライアントに追加してください。

{
  "mcpServers": {
    "k8s": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/k8s-mcp",
        "run",
        "k8s-mcp"
      ],
      "env": {
        "KUBECONFIG_ALIASES": "development=dev production=prod",
        "KUBECONFIG_URLS": "dev=file:///path/to/development/k3s/kubeconfig.yaml prod=file:///path/to/production/k3s/kubeconfig.yaml",
        "PORT_FORWARD_CONFIG_URL": "file:///path/to/k8s-mcp/port-forward-config.yaml"
      }
    }
  }
}

K8s MCP Server のツール

ツール一覧はまだありません

この掲載には表示できるツール一覧がまだありません。サーバーにツールがないという意味ではありません。対応機能はプロジェクトのドキュメントをご確認ください。

ツールは README から自動的に抽出されます。メンテナーは ## Tools という見出しの下に記載することで、このタブに反映できます。

概要

What is K8s MCP Server?

K8s MCP Server is an AI-friendly Kubernetes access tool that supports enhanced port‑forward management, headless services, and kubectl‑inspired output formats. It is designed for AI agents and developers who need efficient, context‑aware interaction with Kubernetes clusters.

How to use K8s MCP Server?

Install dependencies with pip install -e ., set environment variables such as KUBECONFIG_URLS and PORT_FORWARD_CONFIG_URL, then run python main.py. The server provides MCP tools for reading, modifying, and discovering resources, along with port‑forward session management.

Key features of K8s MCP Server

  • kubectl‑inspired output formats (table, wide, json, yaml, custom‑columns, jsonpath)
  • Natural‑language resource kind discovery for CRDs and built‑in resources
  • URL‑based port‑forward configuration via local files or GitHub Gists
  • Headless service support with direct pod targeting via label selectors
  • Token‑efficient AI‑optimized output and multi‑format config files (YAML, JSON, TOML)
  • In‑memory port‑forward session tracking with list and teardown capabilities

Use cases of K8s MCP Server

  • AI agents perform cluster overview, application debugging, and safe deployment updates
  • Automated port‑forward setup for AI workflows (e.g., connecting to a Druid service in development)
  • Resource cleanup and security audits using read‑only or modify tools
  • Performance troubleshooting and disaster recovery with structured tool workflows
  • Multi‑cluster resource discovery and exploration without manual kubectl commands

よくある質問

1

What Kubernetes resources can I list or query?

You can list pods, services, deployments, nodes, events, and any custom resource kind discovered via `discover_resource_kinds`. The server supports plural, singular, and abbreviated resource names (e.g., `pods`, `pod`, `po`), and case‑insensitive input.

2

How does the port‑forward configuration work?

Port‑forward targets are defined in a YAML/JSON/TOML file, referenced by `PORT_FORWARD_CONFIG_URL`. Each target specifies a cluster alias, namespace, label selectors, local port, and remote port. The AI agent can then use `connect_to_service_targets` to set up the forward.

3

Are the tools safe for autonomous AI use?

Tools are classified into three safety levels: **[READ-ONLY]** (safe for autonomous use, e.g., `list_resources`, `get_logs`), **[MODIFIES STATE]** (require user approval, e.g., `apply_manifest`, `connect_to_service_targets`), and **[DANGEROUS]** (require explicit confirmation, e.g., `delete_resource`, `execute_in_pod`).

4

Does K8s MCP Server support headless services?

Yes. For headless services, the server selects the first ready pod using label selectors, mimicking `kubectl port-forward` behavior. This is configured in the port‑forward config file under each service target.

5

What transport or authentication does the server use?

The server uses the MCP stdio transport and relies on existing Kubernetes authentication (kubeconfig) configured via the `KUBECONFIG_URLS` environment variable. It does not implement additional authentication layers.

コメント

「クラウドとインフラ」の他のコンテンツ