mcp-server-kubernetes

MCP server for Kubernetes cluster operations -- pods, deployments, services, namespaces, events, and manifests

TypeScript 5.3+ MCP Server v1.0.0

Executive Summary

An MCP (Model Context Protocol) server that provides AI assistants with comprehensive Kubernetes cluster management capabilities. Built with the official Kubernetes client-node library and MCP SDK, it exposes eight tools for listing pods, deployments, and services, retrieving pod logs, applying manifests, listing namespaces, getting cluster events, and scaling deployments. The server uses kubeconfig or in-cluster authentication and communicates via stdio transport for integration with Claude Desktop and other MCP clients.

Overview

TypeScript
Language
MCP Server
Category
8
Tools
5
K8s Resource Types
4
Dependencies
MIT
License

Architecture Diagram

MCP Client
Claude Desktop / AI Assistant
v
stdio Transport
JSON-RPC over stdin/stdout
v
MCP Server Entry
src/index.ts
<-->
Kube Config Loader
src/kube.ts
Tool Dispatch Layer
v
list_pods
Core v1
list_deployments
Apps v1
list_services
Core v1
get_pod_logs
Core v1
apply_manifest
Dynamic
list_namespaces
Core v1
get_events
Core v1
scale_deployment
Apps v1
v
Kubernetes API Server
Cluster Control Plane
v
Pods
Deployments
Services
Namespaces
Events

Component Breakdown

ComponentFilePurposeKey Dependencies
Server Entrysrc/index.tsMCP server initialization, tool registration, stdio transport@modelcontextprotocol/sdk
Kube Configsrc/kube.tsKubernetes client configuration (kubeconfig or in-cluster)@kubernetes/client-node
List Podssrc/tools/list_pods.tsList pods with namespace and label selector filteringCoreV1Api
List Deploymentssrc/tools/list_deployments.tsList deployments with optional namespace filteringAppsV1Api
List Servicessrc/tools/list_services.tsList services with optional namespace filteringCoreV1Api
Get Pod Logssrc/tools/get_pod_logs.tsRetrieve pod logs with container and tail line optionsCoreV1Api
Apply Manifestsrc/tools/apply_manifest.tsApply a YAML manifest to the clusterKubernetesObjectApi, yaml
List Namespacessrc/tools/list_namespaces.tsList all namespaces in the clusterCoreV1Api
Get Eventssrc/tools/get_events.tsGet cluster events with optional namespace filteringCoreV1Api
Scale Deploymentsrc/tools/scale_deployment.tsScale a deployment to a specified replica countAppsV1Api

Data Flow / Request Flow

  1. Client Request -- An MCP client sends a JSON-RPC tool invocation over stdio with tool name and parameters.
  2. Parameter Validation -- Parameters are validated using Zod schemas specific to each tool.
  3. Kube Auth -- The kube config loader resolves authentication from kubeconfig file or in-cluster service account.
  4. API Call -- The tool handler uses the Kubernetes client-node library to call the cluster API server.
  5. Response Formatting -- Kubernetes API responses are serialized and returned to the MCP client as structured content.

Security Controls

ControlImplementation
AuthenticationKubeconfig file or in-cluster service account token
RBACKubernetes RBAC controls which resources the service account can access
Input ValidationZod schema validation on all tool parameters; YAML parsing for manifests
Transport SecurityTLS for Kubernetes API server communication; stdio for local MCP transport
Namespace IsolationTools support namespace filtering to restrict operations
Manifest ValidationYAML manifests are parsed and validated before application

Industry Adaptation

Healthcare

Monitor HIPAA-compliant workloads on AKS/EKS/GKE, scale healthcare applications, retrieve pod logs for compliance auditing.

Finance

Manage PCI-DSS scoped Kubernetes workloads, monitor deployment status for financial applications, audit cluster events.

DevOps

Deployment management, pod troubleshooting via logs, manifest application for GitOps workflows, auto-scaling operations.

Platform Engineering

Multi-cluster management, namespace provisioning, event monitoring for platform health, deployment scaling for capacity management.

Production Readiness Checklist

Configuration / Environment Variables

VariableRequiredDefaultDescription
KUBECONFIGNo~/.kube/configPath to kubeconfig file (auto-detected in-cluster)

Deployment

Local Development

git clone https://github.com/kogunlowo123/mcp-server-kubernetes.git
cd mcp-server-kubernetes
npm install
npm run build
npm start

Docker / Production

docker build -t mcp-server-kubernetes .
docker run \
  -v ~/.kube/config:/root/.kube/config:ro \
  mcp-server-kubernetes

Links

Repositorygithub.com/kogunlowo123/mcp-server-kubernetes
READMEREADME.md
ChangelogCHANGELOG.md
LicenseMIT License