K8s MCP Server 7daca39c

MCP运维云端

提供方 reza-gholizade

运维云端 stdio · 本地进程 Token 社区 / 第三方 ClaudeVS Code
查看接入方式

一个基于MCP协议的Kubernetes集群交互工具,提供资源管理、日志查看、指标监控等核心功能,适用于Kubernetes集群的开发、调试和运维场景。

一句话选型结论

按资料字段整理

K8s MCP Server 7daca39c 属于运维云端类 MCP 服务器,stdio · 本地进程,Token,可直接接入 Claude、VS Code,有可直接执行的安装命令。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类运维云端 传输方式stdio · 本地进程 鉴权Token 部署方式本地部署
GitHub 星标 156 仓库热度,无公开仓库时显示未标注
工具数 20 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

运维云端
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量20暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

支持客户端

适用场景

Kubernetes工具Go本地部署集群管理运维工具容器编排DevOpsKubernetes管理

安装与配置

stdio · 本地进程 Token
客户端在本机拉起子进程,数据不出本机
docker run -p 8080:8080 -v ~/.kube/config:/home/appuser/.kube/config:ro ginnux/k8s-mcp-server:latest

这条命令只是入口,具体启动参数请按官方文档补齐,不要直接照搬到别的服务器。

  1. 1
    准备运行环境

    stdio 服务在本地起进程,需要先装好 Docker,再按安装命令拉取依赖。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后客户端会列出约 20 个工具,随便调一个只读工具确认能返回结果。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
云资源查询

查实例、存储、账单等云上资源状态。

部署与发布

把部署、重启、回滚这类操作接进对话。

监控与告警

拉取监控指标,异常时让模型帮你判断。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 资料标注 20 个工具,覆盖面较广,能满足多种调用。
  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已适配 Claude、VS Code,换客户端不用重新研究配置。

先想清楚的地方

  • stdio 方式要求本地装好运行时(如 Node.js),换机器要重新装一遍。
  • 使用前要准备好Token对应的凭据,并按最小权限配置。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在运维云端场景里让模型直接调用外部能力的人。
  • 已经在用 Claude、VS Code 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 不方便管理密钥或第三方授权的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
K8s MCP Server 7daca39c当前 20 stdio · 本地进程 本地部署 有 2026-05-17
lobehub 未标注 stdio · 本地进程 本地部署 有 2026-04-11
TrendRadar 未标注 stdio · 本地进程 本地部署 有 2026-04-13
Ui Tars Desktop 8a825770 未标注 stdio · 本地进程 本地部署 有 2026-05-17
ruflo 未标注 stdio · 本地进程 本地部署 有 2026-04-13
FastGPT 未标注 stdio · 本地进程 本地部署 有 2026-04-11

服务器档案

运维云端
字段来自项目仓库与公开索引,中文说明由本站标注
提供方reza-gholizade上游标注的维护方 reza-gholizade
分类运维云端本站按上游分类展示
连接方式stdio · 本地进程客户端在本机拉起子进程,数据不出本机
鉴权方式Token远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · Docker本地安装时用到的包标识与运行时
部署类型本地部署上游给出的部署形态
最近核验2026-05-17上游最后核验时间

详细介绍

31.0 KB
来自项目仓库与上游目录的原文,未做删改

Kubernetes MCP Server

A Kubernetes Model Context Protocol (MCP) server that provides tools for interacting with Kubernetes clusters through a standardized interface.

Hosted deployment

A hosted deployment is available on Fronteir AI.

Features

  • API Resource Discovery: Get all available API resources in your Kubernetes cluster.
  • Resource Listing: List resources of any type with optional namespace and label filtering.
  • Resource Details: Get detailed information about specific Kubernetes resources.
  • Resource Description: Get comprehensive descriptions of Kubernetes resources, similar to kubectl describe.
  • Pod Logs: Retrieve logs from specific pods (optionally from a specific container, or all containers if unspecified).
  • Node Metrics: Get resource usage metrics for specific nodes.
  • Pod Metrics: Get CPU and Memory metrics for specific pods.
  • Event Listing: List events within a namespace or for a specific resource.
  • Resource Creation/Updating: Create new Kubernetes resources or update existing ones from a YAML or JSON manifest.
  • Resource Deletion: It deletes a resource in the Kubernetes cluster based on the provided namespace and kind.
  • Standardized Interface: Uses the MCP protocol for consistent tool interaction.
  • Flexible Configuration: Supports different Kubernetes contexts and resource scopes.
  • Multiple Modes: Run in stdio mode for CLI tools, sse mode, or streamable-http mode for web applications, and --readonly for no change in the cluster.
  • Security: Runs as non-root user in Docker containers for enhanced security.

Prerequisites

  • Go 1.23 or later
  • Access to a Kubernetes cluster
  • kubectl configured with appropriate cluster access

Installation

  1. Clone the repository:bash git clone https://github.com/reza-gholizade/k8s-mcp-server.git cd k8s-mcp-server

  2. Install dependencies:bash go mod download

  3. Build the server:bash go build -o k8s-mcp-server .

Usage

Starting the Server

The server can run in three modes, configurable via command-line flags or environment variables.

Stdio Mode (for CLI integrations)

This mode uses standard input/output for communication.```bash
./k8s-mcp-server --mode stdio

Or using environment variables:```bash
SERVER_MODE=stdio ./k8s-mcp-server

SSE Mode (for web applications)

This mode starts an HTTP server with Server-Sent Events support.

HTTP transports require a bearer token and listen on loopback by default:```bash
MCP_AUTH_TOKEN="$(openssl rand -hex 32)" ./k8s-mcp-server --mode sse

Specify a port:```bash
MCP_AUTH_TOKEN="your-random-secret" ./k8s-mcp-server --mode sse --port 9090

Or using environment variables:```bash
SERVER_MODE=sse SERVER_PORT=9090 MCP_AUTH_TOKEN="your-random-secret" ./k8s-mcp-server

#### Streamable-HTTP Mode (for web applications)
This mode starts an HTTP server with streamable-http transport support, following the MCP specification.

Default (port 8080):```bash
MCP_AUTH_TOKEN="your-random-secret" ./k8s-mcp-server --mode streamable-http

Specify a port:```bash
MCP_AUTH_TOKEN="your-random-secret" ./k8s-mcp-server --mode streamable-http --port 9090

Or using environment variables:```bash
SERVER_MODE=streamable-http SERVER_PORT=9090 MCP_AUTH_TOKEN="your-random-secret" ./k8s-mcp-server

The server will be available at http://localhost:8080/mcp (or your specified port).

If no mode is specified, the server defaults to stdio. HTTP modes bind to
127.0.0.1 by default. Set SERVER_HOST=0.0.0.0 (or --host 0.0.0.0) only
when network access is intentional, and send Authorization: Bearer
on every MCP request. Browser clients must also be explicitly allowed with a
comma-separated MCP_ALLOWED_ORIGINS value.

The unauthenticated /healthz endpoint is available for container health checks;
it does not expose MCP functionality.

Kubernetes Authentication

The server supports multiple authentication methods, which are tried in the following order of priority:

1. Kubeconfig Content from Environment Variable

You can provide the entire kubeconfig file content via the KUBECONFIG_DATA environment variable:```bash
export KUBECONFIG_DATA="$(cat ~/.kube/config)"
./k8s-mcp-server


This is useful when you want to avoid mounting files or when running in environments where file access is restricted.

#### 2. API Server URL and Token

You can authenticate using a Kubernetes API server URL and bearer token:```bash
export KUBERNETES_SERVER="https://kubernetes.example.com:6443"
export KUBERNETES_TOKEN="your-bearer-token-here"
./k8s-mcp-server

Optional environment variables for TLS configuration:
- KUBERNETES_CA_CERT: CA certificate content (base64-encoded or PEM format)
- KUBERNETES_CA_CERT_PATH: Path to CA certificate file
- KUBERNETES_INSECURE: Set to "true" to skip TLS verification (not recommended for production)

Example with CA certificate:```bash
export KUBERNETES_SERVER="https://kubernetes.example.com:6443"
export KUBERNETES_TOKEN="your-bearer-token-here"
export KUBERNETES_CA_CERT_PATH="/path/to/ca.crt"
./k8s-mcp-server


#### 3. In-Cluster Authentication (Service Account)

When running inside a Kubernetes cluster, the server automatically detects and uses the service account token from `/var/run/secrets/kubernetes.io/serviceaccount/token`. This is the recommended method for running the server as a pod within a cluster.

**Example Deployment:**```yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: k8s-mcp-server-sa
  namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: k8s-mcp-server-role
rules:
  - apiGroups: [""]
    resources: ["*"]
    verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
  - apiGroups: ["apps"]
    resources: ["*"]
    verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
  # Add more rules as needed for your use case
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: k8s-mcp-server-rb
subjects:
  - kind: ServiceAccount
    name: k8s-mcp-server-sa
    namespace: default
roleRef:
  kind: ClusterRole
  name: k8s-mcp-server-role
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: k8s-mcp-server
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: k8s-mcp-server
  template:
    metadata:
      labels:
        app: k8s-mcp-server
    spec:
      serviceAccountName: k8s-mcp-server-sa
      containers:
        - name: k8s-mcp-server
          image: ginnux/k8s-mcp-server:latest
          ports:
            - containerPort: 8080
          env:
            - name: SERVER_MODE
              value: "sse"
            - name: SERVER_PORT
              value: "8080"

4. Kubeconfig File Path (Default)

If none of the above methods are available, the server falls back to using a kubeconfig file:

  • Uses the path provided via --kubeconfig flag (if implemented) or KUBECONFIG environment variable
  • Defaults to ~/.kube/config if neither is specified```bash

Using default ~/.kube/config

./k8s-mcp-server

Using custom kubeconfig path

export KUBECONFIG=/path/to/your/kubeconfig
./k8s-mcp-server


**Note:** The server automatically detects which authentication method to use based on the available environment variables and file system. You don't need to explicitly configure the authentication method - it will use the first available method in the priority order listed above.

#### Read-Only Mode

The server supports a read-only mode that disables all write operations, providing a safer way to explore and monitor your Kubernetes cluster without the risk of making changes.

Enable read-only mode with the `--read-only` flag:```bash
./k8s-mcp-server --read-only

You can combine read-only mode with any server mode:```bash

Read-only with stdio mode

./k8s-mcp-server --mode stdio --read-only

Read-only with SSE mode

./k8s-mcp-server --mode sse --read-only

Read-only with streamable-http mode

./k8s-mcp-server --mode streamable-http --read-only


When read-only mode is enabled, the following tools are disabled:
- `createResource` (Kubernetes resource creation/updates)
- `helmInstall` (Helm chart installations)
- `helmUpgrade` (Helm chart upgrades)
- `helmUninstall` (Helm chart uninstallations)
- `helmRollback` (Helm release rollbacks)
- `helmRepoAdd` (Helm repository additions)

All other read-only operations remain available, including listing resources, getting logs, viewing metrics, and inspecting Helm releases.

#### Tool Category Flags
You can selectively disable entire categories of tools using these flags:

**Disable Kubernetes Tools:**```bash
./k8s-mcp-server --no-k8s

Disable Helm Tools:```bash
./k8s-mcp-server --no-helm


**Combine with other flags:**```bash
# Read-only mode with only Kubernetes tools (no Helm)
./k8s-mcp-server --read-only --no-helm

# Read-only mode with only Helm tools (no Kubernetes)
./k8s-mcp-server --read-only --no-k8s

# SSE mode with only Kubernetes tools
./k8s-mcp-server --mode sse --no-helm

Note: You cannot use both --no-k8s and --no-helm together, as this would result in no available tools. The server will exit with an error if both flags are provided.

When --no-k8s is enabled, all Kubernetes tools are disabled:
- getAPIResources, listResources, getResource, describeResource
- getPodsLogs, getNodeMetrics, getPodMetrics, getEvents
- createResource (if not in read-only mode)

When --no-helm is enabled, all Helm tools are disabled:
- helmList, helmGet, helmHistory, helmRepoList
- helmInstall, helmUpgrade, helmUninstall, helmRollback, helmRepoAdd (if not in read-only mode)

Using the Docker Image

You can also run the server using the pre-built Docker image from Docker Hub.

  1. Pull the image:bash docker pull ginnux/k8s-mcp-server:latest
    You can replace latest with a specific version tag (e.g., 1.0.0).

  2. Run the container:

    Note: The server supports multiple authentication methods. You can either mount a kubeconfig file (as shown below) or use environment variables for authentication (see Kubernetes Authentication section above).

    • SSE Mode (default behavior of the image):bash docker run -p 8080:8080 -v ~/.kube/config:/home/appuser/.kube/config:ro ginnux/k8s-mcp-server:latest
      This maps port 8080 of the container to port 8080 on your host and mounts your Kubernetes config read-only to the non-root user's home directory. The server will be available at http://localhost:8080. The image defaults to sse mode on port 8080.

    • Streamable-HTTP Mode:bash docker run -p 8080:8080 -v ~/.kube/config:/home/appuser/.kube/config:ro ginnux/k8s-mcp-server:latest --mode streamable-http
      This runs the server in streamable-http mode. The server will be available at http://localhost:8080/mcp.

    • Stdio Mode:bash docker run -i --rm -v ~/.kube/config:/home/appuser/.kube/config:ro ginnux/k8s-mcp-server:latest --mode stdio
      The -i flag is important for interactive stdio communication. --rm cleans up the container after exit.

    • Custom Port for SSE Mode:bash docker run -p 9090:9090 -v ~/.kube/config:/home/appuser/.kube/config:ro ginnux/k8s-mcp-server:latest --mode sse --port 9090

    • Custom Port for Streamable-HTTP Mode:bash docker run -p 9090:9090 -v ~/.kube/config:/home/appuser/.kube/config:ro ginnux/k8s-mcp-server:latest --mode streamable-http --port 9090

    • Alternative: Mount entire .kube directory:bash docker run -p 8080:8080 -v ~/.kube:/home/appuser/.kube:ro ginnux/k8s-mcp-server:latest

    • Using environment variables for authentication (no file mounting required):```bash
      # Using kubeconfig content from environment variable
      docker run -p 8080:8080 \
      -e KUBECONFIG_DATA="$(cat ~/.kube/config)" \
      ginnux/k8s-mcp-server:latest

      Or using API server URL and token

      docker run -p 8080:8080 \
      -e KUBERNETES_SERVER="https://kubernetes.example.com:6443" \
      -e KUBERNETES_TOKEN="your-token-here" \
      -e KUBERNETES_CA_CERT_PATH="/path/to/ca.crt" \
      -v /path/to/ca.crt:/path/to/ca.crt:ro \
      ginnux/k8s-mcp-server:latest
      ```

Using with Docker Compose

Create a docker-compose.yml file:

Option 1: Using kubeconfig file (traditional method):```yaml
version: '3.8'
services:
k8s-mcp-server:
image: ginnux/k8s-mcp-server:latest # Or a specific version
container_name: k8s-mcp-server
ports:
- "8080:8080" # Host:Container, adjust if using a different SERVER_PORT
volumes:
- ~/.kube:/home/appuser/.kube:ro # Mount kubeconfig read-only to non-root user home
environment:
- KUBECONFIG=/home/appuser/.kube/config
- SERVER_MODE=sse # Can be 'stdio', 'sse', or 'streamable-http'
- SERVER_PORT=8080 # Port for SSE/streamable-http modes
# command: ["--read-only"] # Uncomment this line to enable read-only mode
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s


**Option 2: Using environment variables (no file mounting):**```yaml
version: '3.8'
services:
  k8s-mcp-server:
    image: ginnux/k8s-mcp-server:latest
    container_name: k8s-mcp-server
    ports:
      - "8080:8080"
    environment:
      - KUBECONFIG_DATA=${KUBECONFIG_DATA} # Set this in your .env file or shell
      # Or use API server and token:
      # - KUBERNETES_SERVER=https://kubernetes.example.com:6443
      # - KUBERNETES_TOKEN=${KUBERNETES_TOKEN}
      - SERVER_MODE=sse
      - SERVER_PORT=8080
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s

Note: To enable read-only mode, use the command override as shown in Option 1. For stdio mode, you might need to adjust 'ports', add 'stdin_open: true' and 'tty: true', and potentially override the command.

Then start with:```bash
docker compose up -d

To see logs: `docker compose logs -f k8s-mcp-server`.

#### Security Considerations

The Docker image runs as a non-root user (`appuser` with UID 1001) for enhanced security:
- The application binary is located at `/usr/local/bin/k8s-mcp-server`
- The kubeconfig should be mounted to `/home/appuser/.kube/config`
- Health checks are enabled to monitor container status
- The container includes minimal dependencies (ca-certificates and curl only)

SSE and streamable HTTP are fail-closed unless `MCP_AUTH_TOKEN` is set. Never
publish an HTTP transport without authentication. Prefer `stdio` for local MCP
clients, use `--read-only` where possible, and grant the server's Kubernetes
identity only the RBAC permissions it needs. A session ID is not an authentication
credential. Put remotely accessible deployments behind TLS and an authenticating
reverse proxy, and configure `MCP_ALLOWED_ORIGINS` for browser-based clients.

#### Making API Calls (SSE/Streamable-HTTP Mode)
Once the server is running in SSE or streamable-http mode, you can make JSON-RPC calls to its HTTP endpoint:```bash
curl -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "getAPIResources",
    "arguments": {
      "includeNamespaceScoped": true,
      "includeClusterScoped": true
    }
  }
}' http://localhost:8080/

You can also check the health status:```bash
curl -f http://localhost:8080/


### Available Tools

#### 1. `getAPIResources`

Retrieves all available API resources in the Kubernetes cluster.

**Parameters:**
- `includeNamespaceScoped` (boolean, optional): Whether to include namespace-scoped resources (defaults to true).
- `includeClusterScoped` (boolean, optional): Whether to include cluster-scoped resources (defaults to true).

**Example:**```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "getAPIResources",
    "arguments": {
      "includeNamespaceScoped": true,
      "includeClusterScoped": true
    }
  }
}

2. listResources

Lists all instances of a specific resource type.

Parameters:
- Kind (string, required): The kind of resource to list (e.g., "Pod", "Deployment").
- namespace (string, optional): The namespace to list resources from. If omitted, lists across all namespaces for namespaced resources (subject to RBAC).
- labelSelector (string, optional): Filter resources by label selector (e.g., "app=nginx,env=prod").

Example:```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "listResources",
"arguments": {
"Kind": "Pod",
"namespace": "default",
"labelSelector": "app=nginx"
}
}
}


#### 3. `getResource`

Retrieves detailed information about a specific resource.

**Parameters:**
- `kind` (string, required): The kind of resource to get (e.g., "Pod", "Deployment").
- `name` (string, required): The name of the resource to get.
- `namespace` (string, optional): The namespace of the resource (required for namespaced resources).

**Example:**```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "getResource",
    "arguments": {
      "kind": "Pod",
      "name": "nginx-pod",
      "namespace": "default"
    }
  }
}

4. describeResource

Describes a resource in the Kubernetes cluster, similar to kubectl describe.

Parameters:
- Kind (string, required): The kind of resource to describe (e.g., "Pod", "Deployment").
- name (string, required): The name of the resource to describe.
- namespace (string, optional): The namespace of the resource (required for namespaced resources).

Example:```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "describeResource",
"arguments": {
"Kind": "Pod",
"name": "nginx-pod",
"namespace": "default"
}
}
}


#### 5. `getPodsLogs`

Retrieves the logs of a specific pod.

**Parameters:**
- `Name` (string, required): The name of the pod.
- `namespace` (string, required): The namespace of the pod.
- `containerName` (string, optional): The specific container name within the pod. If omitted:
    - If the pod has one container, its logs are fetched.
    - If the pod has multiple containers, logs from all containers are fetched and concatenated.

**Example:**```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "getPodsLogs",
    "arguments": {
      "Name": "my-app-pod-12345",
      "namespace": "production",
      "containerName": "main-container"
    }
  }
}

6. getNodeMetrics

Retrieves resource usage metrics for a specific node.

Parameters:
- Name (string, required): The name of the node.

Example:```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "getNodeMetrics",
"arguments": {
"Name": "worker-node-1"
}
}
}


#### 7. `getPodMetrics`

Retrieves CPU and Memory metrics for a specific pod.

**Parameters:**
- `namespace` (string, required): The namespace of the pod.
- `podName` (string, required): The name of the pod.

**Example:**```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "getPodMetrics",
    "arguments": {
      "namespace": "default",
      "podName": "my-app-pod-67890"
    }
  }
}

8. getEvents

Retrieves events for a specific namespace or resource.

Parameters:
- namespace (string, optional): The namespace to get events from. If omitted, events from all namespaces are considered (subject to RBAC).
- resourceName (string, optional): The name of a specific resource (e.g., a Pod name) to filter events for.
- resourceKind (string, optional): The kind of the specific resource (e.g., "Pod") if resourceName is provided.

Example (Namespace Events):```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "getEvents",
"arguments": {
"namespace": "default"
}
}
}


**Example (Resource Events):**```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "getEvents",
    "arguments": {
      "namespace": "production",
      "resourceName": "my-app-pod-12345",
      "resourceKind": "Pod"
    }
  }
}

9. createOrUpdateResource

Creates a new resource or updates an existing one from a JSON manifest.

Parameters:
- manifest (string, required): The JSON manifest of the resource.
- namespace (string, optional): The namespace in which to create/update the resource. If the manifest contains a namespace, this parameter can be used to override it. If not provided and the manifest doesn't specify one, "default" might be assumed or it might be an error depending on the resource type.

Example:```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "createResource",
"arguments": {
"kind": "Deployment",
"namespace": "default",
"manifest": "{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"metadata\":{\"name\":\"nginx-deployment\"},\"spec\":{\"replicas\":1,\"selector\":{\"matchLabels\":{\"app\":\"nginx\"}},\"template\":{\"metadata\":{\"labels\":{\"app\":\"nginx\"}},\"spec\":{\"containers\":[{\"name\":\"nginx\",\"image\":\"nginx:latest\"}]}}}}"
}
}
}


#### 10. `createResourceYAML`

Creates a new resource or updates an existing one from a YAML manifest. This tool is specifically optimized for YAML input and provides better error handling for YAML parsing issues.

**Parameters:**
- `yamlManifest` (string, required): The YAML manifest of the resource.
- `namespace` (string, optional): The namespace in which to create/update the resource. If the manifest contains a namespace, this parameter can be used to override it. If not provided and the manifest doesn't specify one, "default" might be assumed or it might be an error depending on the resource type.
- `kind` (string, optional): The kind of the resource. If not provided, the kind will be inferred from the YAML manifest.

**Example:**```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "createResourceYAML",
    "arguments": {
      "namespace": "default",
      "yamlManifest": "apiVersion: v1\nkind: Pod\nmetadata:\n  name: my-new-pod\nspec:\n  containers:\n  - name: nginx\n    image: nginx:latest"
    }
  }
}

11. rolloutRestart

Triggers a rolling restart of a Kubernetes resource that supports spec.template.metadata.annotations. This includes Deployment, DaemonSet, StatefulSet, Job, and similar resources.

Parameters:
- kind (string, required): The kind of resource (e.g., "Deployment", "StatefulSet").
- name: (string, required): The name of the resource to restart.
- namespace (string, required for namespaced resources): The namespace of the resource.

Example (StatefulSet):```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "rolloutRestart",
"arguments": {
"kind": "StatefulSet",
"name": "redis-cluster-01",
"namespace": "default"
}
}
}

**Example (Deployment):**```json
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "rolloutRestart",
    "arguments": {
      "kind": "Deployment",
      "name": "my-app-deployment",
      "namespace": "default"
    }
  }
}

12. deleteResource

Deletes a specific resource from the Kubernetes cluster.

Parameters:
- kind (string, required): The type of resource to delete.
- name (string, required): The name of the resource to delete.
- namespace (string, optional): The namespace of the resource (required for namespaced resources).

Example:```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "deleteResource",
"arguments": {
"kind": "Pod",
"name": "my-pod",
"namespace": "default"
}
}
}


#### 13. `getIngresses`

Retrieves ingress resources from the Kubernetes cluster.
You can filter ingresses by host. If no host is provided, all ingresses are returned.

**Parameters:**
- `host` (string, optional): The host to filter ingresses by. If omitted, all ingresses are included.

**Example:**```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "getIngresses",
    "arguments": {
      "host": "example.com"
    }
  }
}

Helm Operations

14. helmInstall

Install a Helm chart to the Kubernetes cluster.

Parameters:
- releaseName (string, required): Name of the Helm release
- chartName (string, required): Name or path of the Helm chart
- namespace (string, optional): Kubernetes namespace for the release (defaults to "default")
- repoURL (string, optional): Helm repository URL
- values (object, optional): Values to override in the chart

Example:```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "helmInstall",
"arguments": {
"releaseName": "my-nginx",
"chartName": "bitnami/nginx",
"namespace": "web",
"repoURL": "https://charts.bitnami.com/bitnami",
"values": {
"replicaCount": 3,
"service": {
"type": "LoadBalancer"
}
}
}
}
}


#### 15. `helmUpgrade`

Upgrade an existing Helm release.

**Parameters:**
- `releaseName` (string, required): Name of the Helm release
- `chartName` (string, required): Name or path of the Helm chart
- `namespace` (string, required): Kubernetes namespace for the release (defaults to "default")
- `repoURL` (string, optional): Helm repository URL; omit it for local chart paths or charts resolvable from configured repositories
- `values` (object, required): Values to override in the chart
  **Example:**```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "helmUpgrade",
    "arguments": {
      "releaseName": "my-nginx",
      "chartName": "nginx",
      "namespace": "web",
      "repoURL": "https://charts.bitnami.com/bitnami",
      "values": {
        "replicaCount": 2,
        "service": {
          "type": "NodePort"
        }
      }
    }
  }
}

16. helmList

List all Helm releases in the cluster or a specific namespace.

17. helmGet

Get details of a specific Helm release.

18. helmHistory

Get the history of a Helm release.

19. helmRollback

Rollback a Helm release to a previous revision.

20. helmUninstall

Uninstall a Helm release from the Kubernetes cluster.

Adding New Tools

  1. Define the Tool: In tools/tools.go, define a function that returns an mcp.Tool structure. This includes the tool's name, description, and input/output schemas.
  2. Implement the Handler: In handlers/handlers.go, create a handler function. This function takes *k8s.Client as an argument and returns a function with the signature func(context.Context, mcp.ToolInput) (mcp.ToolOutput, error). This inner function will contain the logic for your tool.
  3. Register the Tool: In main.go, add your new tool to the MCP server instance using s.AddTool(tools.YourToolDefinitionFunction(), handlers.YourToolHandlerFunction(client)).

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details on how to contribute to this project.

License

gholizade.net@gmail.com

This project is licensed under the MIT License - see the LICENSE file for details.

VS Code Integration

Quick Setup

Automatic Installation (Recommended)

macOS/Linux:```bash
curl -sSL https://raw.githubusercontent.com/reza-gholizade/k8s-mcp-server/main/scripts/install-vscode-config.sh | bash


**Windows (PowerShell):**```powershell
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/reza-gholizade/k8s-mcp-server/main/scripts/install-vscode-config.ps1'))

Manual Installation

  1. Install the MCP extension in VS Code:bash code --install-extension modelcontextprotocol.mcp

  2. Add to your VS Code settings.json:

Open VS Code settings (Cmd/Ctrl + ,) → Open Settings JSON → Add:

macOS/Linux:json { "mcp.mcpServers": { "k8s-mcp-server": { "command": "k8s-mcp-server", "args": ["--mode", "stdio"], "env": { "KUBECONFIG": "${env:HOME}/.kube/config" } } } }

Read-Only Mode (recommended for safety):json { "mcp.mcpServers": { "k8s-mcp-server": { "command": "k8s-mcp-server", "args": ["--mode", "stdio", "--read-only"], "env": { "KUBECONFIG": "${env:HOME}/.kube/config" } } } }

Kubernetes Tools Only:json { "mcp.mcpServers": { "k8s-mcp-server": { "command": "k8s-mcp-server", "args": ["--mode", "stdio", "--no-helm"], "env": { "KUBECONFIG": "${env:HOME}/.kube/config" } } } }

Helm Tools Only:json { "mcp.mcpServers": { "k8s-mcp-server": { "command": "k8s-mcp-server", "args": ["--mode", "stdio", "--no-k8s"], "env": { "KUBECONFIG": "${env:HOME}/.kube/config" } } } }

Read-Only with Kubernetes Tools Only:```json
{
"mcp.mcpServers": {

…(正文过长,页面只展示前面部分,完整内容见仓库)
```

常见问题

8 问
答案由本站依据条目字段整理,不引用上游原文
K8s MCP Server 7daca39c 怎么安装?

在客户端按下面的安装命令接入:docker run -p 8080:8080 -v ~/.kube/config:/home/appuser/.kube/config:ro ginnux/k8s-mcp-server:latest。装完在客户端配置里引用同一个包或端点。

K8s MCP Server 7daca39c 怎么在 Claude、VS Code 里配置?

它的传输方式是stdio · 本地进程,在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,配置才会生效。

K8s MCP Server 7daca39c 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

K8s MCP Server 7daca39c 需要 API Key 吗?

资料标注需要Token认证,使用前准备好对应凭据,并按最小权限配置。

K8s MCP Server 7daca39c 支持哪些客户端?

资料标注支持 Claude、VS Code;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

K8s MCP Server 7daca39c 能提供哪些能力?

资料显示约 20 个工具;能力标签包括 集群管理、Go、Claude、容器编排。具体工具清单以官方文档为准。

K8s MCP Server 7daca39c 需要什么运行环境?

运行时为 Docker;属于本地进程,需要在本机装好运行环境。

K8s MCP Server 7daca39c 是本地还是远程?

它是本地进程(stdio),由客户端在本机拉起。传输方式为stdio · 本地进程。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 2026-05-17。