Skip to main content
Glama

kubernetes-mcp

by kkb0318
MIT License
22

Kubernetes MCP Server

https://github.com/user-attachments/assets/89df70b0-65d1-461c-b4ab-84b2087136fa

A Model Context Protocol (MCP) server that provides safe, read-only access to Kubernetes resources for debugging and inspection. Built with security in mind, it offers comprehensive cluster visibility without modification capabilities.

Features

  • 🔒 Read-only security: Safely inspect Kubernetes resources without modification capabilities
  • 🎯 CRD support: Works seamlessly with any Custom Resource Definitions in your cluster
  • 🔍 Smart discovery: Find resources by API group substring (e.g., "flux" for FluxCD, "argo" for ArgoCD)
  • ⚡ High performance: Efficient resource querying with filtering and pagination
  • 🛠️ Comprehensive toolset:
    • list_resources: List and filter Kubernetes resources with advanced options
    • describe_resource: Get detailed information about specific resources
    • get_pod_logs: Retrieve pod logs with sophisticated filtering capabilities
    • list_events: List and filter Kubernetes events for debugging and monitoring

🚀 Quick Start

Prerequisites

  • Kubernetes cluster access with a valid kubeconfig file
  • Go 1.24+ (for building from source)

Installation Options

go install github.com/kkb0318/kubernetes-mcp@latest

The binary will be available at $GOPATH/bin/kubernetes-mcp (or $HOME/go/bin/kubernetes-mcp if GOPATH is not set).

Option 2: Build from Source
git clone https://github.com/kkb0318/kubernetes-mcp.git cd kubernetes-mcp go build -o kubernetes-mcp .

⚙️ Configuration

MCP Server Setup

Add the server to your MCP configuration:

Basic Configuration

Uses ~/.kube/config automatically:

{ "mcpServers": { "kubernetes": { "command": "/path/to/kubernetes-mcp" } } }
Custom Kubeconfig
{ "mcpServers": { "kubernetes": { "command": "/path/to/kubernetes-mcp", "env": { "KUBECONFIG": "/path/to/your/kubeconfig" } } } }

Note: Replace /path/to/kubernetes-mcp with your actual binary path.

Standalone Usage

# Default kubeconfig (~/.kube/config) ./kubernetes-mcp # Custom kubeconfig path KUBECONFIG=/path/to/your/kubeconfig ./kubernetes-mcp

Important: Ensure you have appropriate read permissions for the Kubernetes resources you want to inspect.

🛠️ Available Tools

list_resources

List and filter Kubernetes resources with advanced capabilities.

ParameterTypeDescription
kindrequiredResource type (Pod, Deployment, Service, etc.) or "all" for discovery
groupFilteroptionalFilter by API group substring for project-specific resources
namespaceoptionalTarget namespace (defaults to all namespaces)
labelSelectoroptionalFilter by labels (e.g., "app=nginx")
fieldSelectoroptionalFilter by fields (e.g., "metadata.name=my-pod")
limitoptionalMaximum number of resources to return
timeoutSecondsoptionalRequest timeout (default: 30s)
showDetailsoptionalReturn full resource objects instead of summary

Examples:

// List pods with label selector { "kind": "Pod", "namespace": "default", "labelSelector": "app=nginx" } // Discover FluxCD resources { "kind": "all", "groupFilter": "flux" }

describe_resource

Get detailed information about a specific Kubernetes resource.

ParameterTypeDescription
kindrequiredResource type (Pod, Deployment, etc.)
namerequiredResource name
namespaceoptionalTarget namespace

Example:

{ "kind": "Pod", "name": "nginx-pod", "namespace": "default" }

get_pod_logs

Retrieve pod logs with sophisticated filtering options.

ParameterTypeDescription
namerequiredPod name
namespaceoptionalPod namespace (defaults to "default")
containeroptionalSpecific container name
tailoptionalNumber of lines from the end (default: 100)
sinceoptionalDuration like "5s", "2m", "3h"
sinceTimeoptionalRFC3339 timestamp
timestampsoptionalInclude timestamps in output
previousoptionalGet logs from previous container instance

Example:

{ "name": "nginx-pod", "namespace": "default", "tail": 50, "since": "5m", "timestamps": true }

list_events

List and filter Kubernetes events with advanced filtering options for debugging and monitoring.

ParameterTypeDescription
namespaceoptionalTarget namespace (leave empty for all namespaces)
objectoptionalFilter by object name (e.g., pod name, deployment name)
eventTypeoptionalFilter by event type: "Normal" or "Warning" (case-insensitive)
reasonoptionalFilter by event reason (e.g., "Pulled", "Failed", "FailedScheduling")
sinceoptionalDuration like "5s", "2m", "1h"
sinceTimeoptionalRFC3339 timestamp (e.g., "2025-06-20T10:00:00Z")
limitoptionalMaximum number of events to return (default: 100)
timeoutSecondsoptionalRequest timeout (default: 30s)

Examples:

// List recent warning events { "eventType": "Warning", "since": "30m" } // List events for a specific pod { "object": "nginx-pod", "namespace": "default" } // List failed scheduling events { "reason": "FailedScheduling", "limit": 50 }

🌟 Advanced Features

🎯 Custom Resource Definition (CRD) Support

Automatically discovers and works with any CRDs in your cluster. Simply use the CRD's Kind name with list_resources or describe_resource tools.

🔍 Smart Resource Discovery

Use the groupFilter parameter to discover resources by API group substring:

FilterDiscoversExamples
"flux"FluxCD resourcesHelmReleases, Kustomizations, GitRepositories
"argo"ArgoCD resourcesApplications, AppProjects, ApplicationSets
"istio"Istio resourcesVirtualServices, DestinationRules, Gateways
"cert-manager"cert-manager resourcesCertificates, Issuers, ClusterIssuers

🔒 Security & Safety

Built with security as a primary concern:

  • Read-only access - No resource creation, modification, or deletion
  • Production safe - Secure for use in production environments
  • Minimal permissions - Only requires read access to cluster resources
  • No destructive operations - Cannot harm your cluster

🤝 Contributing

We welcome contributions! Please ensure all changes maintain the read-only nature of the server and include appropriate tests.

📄 License

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

-
security - not tested
A
license - permissive license
-
quality - not tested

A Model Context Protocol (MCP) server that provides safe, read-only access to Kubernetes resources for debugging and inspection. Built with security in mind, it offers comprehensive cluster visibility without modification capabilities.

  1. Features
    1. 🚀 Quick Start
      1. Prerequisites
      2. Installation Options
    2. ⚙️ Configuration
      1. MCP Server Setup
      2. Standalone Usage
    3. 🛠️ Available Tools
      1. list_resources
      2. describe_resource
      3. get_pod_logs
      4. list_events
    4. 🌟 Advanced Features
      1. 🎯 Custom Resource Definition (CRD) Support
      2. 🔍 Smart Resource Discovery
      3. 🔒 Security & Safety
    5. 🤝 Contributing
      1. 📄 License

        Related MCP Servers

        • -
          security
          A
          license
          -
          quality
          MCP Server simplifies the implementation of the Model Context Protocol by providing a user-friendly API to create custom tools and manage server workflows efficiently.
          Last updated -
          4
          3
          TypeScript
          MIT License
        • -
          security
          A
          license
          -
          quality
          MCP Server provides a simpler API to interact with the Model Context Protocol by allowing users to define custom tools and services to streamline workflows and processes.
          Last updated -
          13
          2
          TypeScript
          MIT License
        • -
          security
          F
          license
          -
          quality
          A Kubernetes-deployed server for the Model Context Protocol that enables secure communication with configurable environment variables, health monitoring, and scalable deployment on Azure Kubernetes Service.
          Last updated -
          664
          TypeScript

        View all related MCP servers

        MCP directory API

        We provide all the information about MCP servers via our MCP API.

        curl -X GET 'https://glama.ai/api/mcp/v1/servers/kkb0318/kubernetes-mcp'

        If you have feedback or need assistance with the MCP directory API, please join our Discord server