mcp-k8s

krmcbride/mcp-k8s

3.2

If you are the rightful owner of mcp-k8s and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A Model Context Protocol (MCP) server designed for safe, read-only interaction with Kubernetes clusters, focusing on observability and debugging without the risk of accidental changes.

Tools
  1. list_k8s_resources

    List Kubernetes resources of any type with custom formatting for common resource types.

  2. list_k8s_api_resources

    List available Kubernetes API resource types for discovering what resource types are available in the cluster.

  3. get_k8s_resource

    Fetch a single Kubernetes resource with optional Go template formatting for advanced output customization.

  4. get_k8s_metrics

    Get CPU and memory usage metrics for nodes or pods, similar to kubectl top, with optional filtering by name.

  5. get_k8s_pod_logs

    Get logs from a Kubernetes pod, similar to kubectl logs, with options for container selection, time filtering, tail lines, and previous container logs.

mcp-k8s

A Model Context Protocol (MCP) server that provides read-only tools for safely interacting with Kubernetes clusters. This server is designed to be safe for production use, deliberately excluding any tools that could mutate cluster state or cause side effects.

Design Philosophy

This MCP server is intentionally read-only and focuses on observability and debugging. It does not include tools that could:

  • Modify or delete resources (no kubectl apply, delete, patch, etc.)
  • Execute commands in containers (no kubectl exec)
  • Scale deployments or modify replica counts
  • Create port forwards or expose services
  • Drain nodes or perform other cluster maintenance operations

This makes it safe to use for debugging production issues without risk of accidental changes.

Tools

  • list_k8s_resources - List Kubernetes resources of any type with custom formatting for common resource types (pods, deployments, services, etc.)
  • list_k8s_api_resources - List available Kubernetes API resource types (equivalent to kubectl api-resources) for discovering what resource types are available in the cluster
  • get_k8s_resource - Fetch a single Kubernetes resource with optional Go template formatting for advanced output customization
  • get_k8s_metrics - Get CPU and memory usage metrics for nodes or pods, similar to kubectl top, with optional filtering by name (CPU in millicores, memory in MiB). Optional sum parameter adds TOTAL entry to results.
  • get_k8s_pod_logs - Get logs from a Kubernetes pod, similar to kubectl logs, with options for container selection, time filtering, tail lines, and previous container logs.

Resources

  • kubeconfig://contexts - Lists available Kubernetes contexts from your kubeconfig file, showing context names, cluster names, and which context is currently active. Use this resource to resolve cluster aliases (like 'prod', 'sandbox') to actual context names instead of running kubectl commands. Returns JSON with context-to-cluster mappings.

Prompts

  • memory_pressure_analysis - Analyzes pods for memory pressure issues, including:

    • Pods with memory usage close to their configured limits (>80%)
    • Pods with memory usage significantly exceeding their requests (>120%)
    • Pods that have been OOM killed

    Arguments:

    • context (required) - The Kubernetes context to use for the analysis
    • namespace (optional) - The namespace to analyze (defaults to all namespaces)

    The prompt guides the assistant to use the get_k8s_metrics and list_k8s_resources tools to identify problematic pods and provide actionable recommendations.

  • workload_instability_analysis - Analyzes Events and pod logs for signs of workload instability, including:

    • Warning Events and failed operations (FailedMount, FailedScheduling, etc.)
    • Error patterns in pod logs (ERROR, FATAL, PANIC messages)
    • Authentication/authorization failures and network connectivity issues
    • Resource exhaustion indicators and application crashes

    Arguments:

    • context (required) - The Kubernetes context to use for the analysis
    • namespace (required) - The namespace to analyze for workload instability

    The prompt guides the assistant to systematically analyze Events and pod logs across all containers, providing a prioritized summary from critical to informational findings.