Kubernetes MCP Server

Kubernetes MCP Server

An MCP server for generating Kubernetes manifests (deployments, services, configmaps, secrets, ingresses, namespaces) and performing kubectl operations like apply, delete, get, describe, logs, and exec.

Category
Visit Server

README

Kubernetes MCP Server

An MCP server that provides tools for generating Kubernetes YAML manifests and deploying using kubectl.

Features

Manifest Generation

  • generate_deployment: Create Deployment manifests with resource limits, env vars
  • generate_service: Create Service manifests (ClusterIP, NodePort, LoadBalancer)
  • generate_configmap: Create ConfigMap manifests
  • generate_secret: Create Secret manifests (auto base64 encoding)
  • generate_ingress: Create Ingress manifests with optional TLS
  • generate_namespace: Create Namespace manifests

Kubectl Operations

  • kubectl_apply: Apply manifests to cluster
  • kubectl_delete: Delete resources from cluster
  • kubectl_get: List resources
  • kubectl_describe: Describe resources in detail
  • kubectl_logs: Get pod logs
  • kubectl_exec: Execute commands in pods

Prerequisites

  • Python 3.10+
  • kubectl installed and configured
  • Access to a Kubernetes cluster (kubeconfig set up)

Installation

cd kubernetes-mcp-server
pip install -r requirements.txt

Kubernetes Access

Ensure kubectl is configured:

# Verify connection
kubectl cluster-info

# Check current context
kubectl config current-context

# List available contexts
kubectl config get-contexts

Configuration

Add to your Claude Code settings (~/.claude/settings.json):

{
  "mcpServers": {
    "kubernetes": {
      "command": "python",
      "args": ["/Users/youruser/Documents/Base/DevOps-ClaudeAi/test-cases/SM1/my-first-vpc/kubernetes-mcp-server/server.py"]
    }
  }
}

Usage Examples

Generate Manifests

User: "Generate a deployment for nginx with 3 replicas"
Claude: [calls generate_deployment with name=nginx, image=nginx:latest, replicas=3]

User: "Create a LoadBalancer service for the nginx deployment"
Claude: [calls generate_service with service_type=LoadBalancer, selector={app: nginx}]

User: "Generate a configmap with database connection settings"
Claude: [calls generate_configmap with data]

Deploy to Cluster

User: "Apply the nginx deployment to the cluster"
Claude: [calls kubectl_apply with manifest path]

User: "Get all pods in the default namespace"
Claude: [calls kubectl_get with resource_type=pods, namespace=default]

User: "Show me the logs from the nginx pod"
Claude: [calls kubectl_logs with pod_name]

Manifest Storage

Generated manifests are automatically saved to ~/k8s-manifests/ with timestamps:

  • deployment-nginx_20260417_143022.yaml
  • service-nginx_20260417_143045.yaml

This allows you to:

  • Track generated configurations
  • Version control your manifests
  • Re-apply manifests later
  • Review what was created

Security Notes

⚠️ IMPORTANT:

  • This server can deploy resources to your Kubernetes cluster
  • Always review generated manifests before applying
  • Use RBAC to limit kubectl permissions
  • Be cautious with kubectl_exec (can run arbitrary commands in pods)
  • Secrets are base64 encoded (not encrypted) - use proper secret management solutions

Recommended RBAC Policy

Create a ServiceAccount with limited permissions:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: mcp-deployer
  namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: mcp-deployer-role
  namespace: default
rules:
- apiGroups: ["", "apps", "networking.k8s.io"]
  resources: ["deployments", "services", "configmaps", "secrets", "ingresses"]
  verbs: ["get", "list", "create", "update", "patch"]
- apiGroups: [""]
  resources: ["pods", "pods/log"]
  verbs: ["get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: mcp-deployer-binding
  namespace: default
subjects:
- kind: ServiceAccount
  name: mcp-deployer
roleRef:
  kind: Role
  name: mcp-deployer-role
  apiGroup: rbac.authorization.k8s.io

Working with Multiple Clusters

Use the context parameter to target different clusters:

User: "Deploy to production cluster"
Claude: [calls kubectl_apply with context=prod-cluster]

User: "List pods in staging"
Claude: [calls kubectl_get with context=staging-cluster]

Error Handling

The server provides detailed kubectl error messages:

  • Resource already exists
  • Permission denied (RBAC)
  • Invalid manifest syntax
  • Connection errors
  • Resource not found

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured