k8scortex-mcp

k8scortex-mcp

A production-grade MCP server providing a secure, natural-language interface to Kubernetes for developers and AI agents, with multi-cluster routing, OIDC authentication, RBAC, and audit logging.

Category
访问服务器

README

K8sCortex — Kubernetes MCP Server

smithery badge npm version License: MIT

A production-grade Model Context Protocol (MCP) server that gives developers, AI agents, and automation pipelines a single, secure, natural-language interface to Kubernetes — across any cloud, any cluster, any team.


Features

  • Curated multi-domain toolset across workload, deployment, configuration, observability, jobs, networking, GitOps, cluster admin, and generic read paths
  • Multi-cluster routing — target any registered cluster with a single cluster parameter
  • Entra ID OIDC authentication with per-tool RBAC (5-tier role hierarchy)
  • Structured audit logging — every tool call recorded with caller identity, arguments, and outcome
  • Dual transport — SSE/HTTP for programmatic clients + stdio for Claude Desktop
  • Azure Key Vault integration for dynamic credential management with 5-minute TTL cache
  • Dry-run safety — destructive tools default to simulation mode
  • Generic read coverage — list/get support for resources outside curated write paths to avoid troubleshooting dead-ends

Install via npx (Fastest)

npx k8scortex-mcp

Or install globally:

npm install -g k8scortex-mcp

Quick Start

Prerequisites

  • Node.js ≥ 18
  • A Kubernetes cluster (minikube, Rancher Desktop, or AKS)
  • kubectl configured with a valid context

Install & Run

# Clone
git clone https://github.com/apatilgtn/k8scortex-mcp.git
cd k8scortex-mcp

# Install
npm install

# Build
npm run build

# Run (local dev mode — auth bypassed)
DISABLE_AUTH=true PORT=3001 npm run dev

Connect with MCP Inspector

npx @modelcontextprotocol/inspector sse http://localhost:3001/mcp

Connect with Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "k8scortex": {
      "command": "node",
      "args": ["<path-to>/k8scortex-mcp/dist/stdio.js"],
      "env": {
        "DISABLE_AUTH": "true",
        "KUBECONFIG": "~/.kube/config"
      }
    }
  }
}

Restart Claude Desktop. Ask: "List all pods in the default namespace".


Tools

K8sCortex intentionally keeps writes curated and governed, while allowing flexible read access for diagnostics.

Domain Tool Description
Workload list_pods List pods with status and IP
Workload get_pod_logs Fetch container logs
Workload describe_deployment Full deployment spec
Workload list_statefulsets List StatefulSets with rollout status
Workload describe_statefulset Detailed StatefulSet spec/status
Workload list_daemonsets List DaemonSets with scheduling status
Workload describe_daemonset Detailed DaemonSet spec/status
Workload list_nodes Cluster nodes with Ready status
Deploy scale_deployment Scale replicas (dry-run default)
Deploy restart_pod Delete pod to trigger restart
Config get_configmap Read ConfigMap data
Config describe_namespace_quota Resource quota usage
Config list_events Recent namespace events
Config list_persistent_volume_claims PVC status, bound volume, storage class, capacity
Config get_effective_permissions ServiceAccount SubjectAccessReview matrix
Generic Read list_k8s_resources Generic list for arbitrary resource kinds
Generic Read get_k8s_resource Generic get for arbitrary resource kinds
Observe get_hpa_status HPA metrics and scaling
Observe list_warning_events Warning events for triage
Observe get_node_pressure Node memory/disk/PID pressure
Multi list_clusters All registered clusters
Multi get_cluster_info Node count, versions, architecture

For the evolving full catalog, see docs/developer-guide.md.


Managed Risk

The largest functional risk in Kubernetes MCP is dead-end visibility on non-curated resources (for example StatefulSets, DaemonSets, PVCs, or CRDs). KubeNexus addresses this by combining:

  • Governed writes: high-impact operations remain explicit, role-gated, and often dry-run by default.
  • Flexible reads: generic read tools cover arbitrary resource kinds for diagnostics.

This keeps the governance posture strong while preserving practical troubleshooting coverage.


Scope Boundaries (v1)

K8sCortex is designed as a governed platform interface, not an unrestricted Kubernetes super-client.

  • Generic write for any resource: intentionally out of scope in v1. Writes are curated and role-gated by design.
  • Pod exec interactive sessions: intentionally out of scope in v1. This requires stronger session controls and command-level auditing that are planned for a later version.

Architecture

Claude / Prism Agent / CI-CD
        │
        ▼
┌──────────────────────────────┐
│     K8sCortex MCP Server     │
│  OIDC → RBAC → Tool → Audit │
│         │                    │
│   Cluster Store (Key Vault)  │
└──────────┬───────────────────┘
           │
    ┌──────┼──────┐
    ▼      ▼      ▼
   AKS    EKS    GKE

Security

  • Authentication: Entra ID OIDC tokens validated on every request
  • Authorization: Role-based tool access (developer → platform-engineer)
  • Audit: JSON-structured log per invocation with user, tool, args, status
  • Network: ClusterIP only — no public endpoint
  • Credentials: Key Vault with 5-minute TTL cache, no kubeconfigs on disk

Project Structure

src/
├── index.ts              # Express SSE server
├── stdio.ts              # Stdio entry point (Claude Desktop)
├── auth.ts               # OIDC middleware
├── roles.ts              # RBAC role hierarchy
├── audit.ts              # Audit logger
├── context.ts            # AsyncLocalStorage user context
├── cluster-store.ts      # Dynamic K8s client factory
├── kubernetes.ts         # Client re-export
└── tools/
    ├── workload.ts       # list_pods, get_pod_logs, describe_deployment, list_nodes
    ├── deployment.ts     # scale_deployment, restart_pod
    ├── configuration.ts  # get_configmap, describe_namespace_quota, list_events
    ├── observability.ts  # get_hpa_status, list_warning_events, get_node_pressure
    └── multicluster.ts   # list_clusters, get_cluster_info

kubernetes/               # Production manifests
├── namespace.yaml
├── deployment.yaml
├── service.yaml
├── rbac.yaml
├── network-policy.yaml
├── hpa.yaml
├── secret-provider-class.yaml
└── alerts.yaml           # Prometheus alerting rules

docs/
├── developer-guide.md    # End-user documentation
├── operator-runbook.md   # Platform team operations
├── slos.md               # Service level objectives
└── adrs/                 # Architecture decision records
    ├── ADR-001-tool-taxonomy.md
    ├── ADR-002-idp-integration.md
    ├── ADR-003-role-model.md
    └── ADR-004-credential-management.md

Documentation

  • Developer Guide — How to connect, available tools, example queries
  • Operator Runbook — Deploy, upgrade, rotate credentials, incident response
  • SLOs — Availability, latency, and alerting targets

Document Files

  • Word documents are consolidated in docs/docx.
  • Current files:
    • K8sCortex_Cloud_Testing_Publishing_Plan.docx
    • K8sCortex_Project_Plan.docx
    • K8sCortex_Project_Plan_v3.docx
    • K8sCortex_Project_Plan_v4.docx

License

Internal — Platform Engineering

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选