Skip to main content
Glama
MCP Kubernetes Server
by abhijeetka

MCP Kubernetes Server

This is an MCP (Model Context Protocol) server for Kubernetes that provides control over Kubernetes clusters through interactions with LLMs.

Overview

This client allows you to perform common Kubernetes operations through MCP tools. It wraps kubectl commands to provide a simple interface for managing Kubernetes resources. The Model Context Protocol (MCP) enables seamless interaction between language models and Kubernetes operations.

Related MCP server: mcp-kubernetes-server

What is MCP?

Model Context Protocol (MCP) is a framework that enables Language Models to interact with external tools and services in a structured way. It provides:

  • A standardized way to expose functionality to language models

  • Context management for operations

  • Tool discovery and documentation

  • Type-safe interactions between models and tools

Usage Examples

  • Create a new deployment for me with name nginx-app and image nginx:latest in the production namespace with 3 replicas.

  • Update the deployment nginx-app to version 1.19 in the production namespace.

  • Scale the deployment nginx-app to 5 replicas in the production namespace.

  • Get me the pods in the production namespace.

  • Get me all namespaces in the cluster.

  • Get me all nodes in the cluster.

  • Get me all services in the cluster.

  • Get me all deployments in the cluster.

  • Get me all jobs in the cluster.

  • Get me all cronjobs in the cluster.

  • Get me all statefulsets in the cluster.

  • Get me all daemonsets in the cluster.

  • What is the current context.

  • list all contexts.

  • switch to context .

  • Get me the logs of pod in the production namespace.

  • Get me the events in the production namespace.

  • annotate pod with key1=value1 in the production namespace.

  • remove annotation key1 from pod in the production namespace.

  • add label key1=value1 to pod in the production namespace.

  • remove label key1 from pod in the production namespace.

  • expose deployment nginx-app in the production namespace on port 80.

  • port-forward pod,deployment,service with name in the production namespace to local port 8080.

  • delete pod, deployment, service, job, cronjob, statefulset, daemonset with name in the production namespace.

Upcoming Features

  • Create cluster role.

  • delete cluster role.

  • create cluster role binding.

  • delete cluster role binding.

  • create namespace.

  • delete namespace.

  • create service account.

  • delete service account.

  • create role.

  • delete role.

  • create role binding.a

  • delete role binding.

LLM Integration

This MCP client is designed to work seamlessly with Large Language Models (LLMs). The functions are decorated with @mcp.tool(), making them accessible to LLMs through the Model Context Protocol framework.

Example LLM Prompts

LLMs can interact with your Kubernetes cluster using natural language. Here are some example prompts:

  • "Create a new nginx deployment with 3 replicas in the production namespace"

  • "Scale the nginx-app deployment to 5 replicas"

  • "Update the image of nginx-app to version 1.19"

The LLM will interpret these natural language requests and call the appropriate MCP functions with the correct parameters.

Benefits of LLM Integration

  1. Natural Language Interface: Manage Kubernetes resources using conversational language

  2. Reduced Command Complexity: No need to remember exact kubectl syntax

  3. Error Prevention: LLMs can validate inputs and provide helpful error messages

  4. Context Awareness: LLMs can maintain context across multiple operations

  5. Structured Interactions: MCP ensures type-safe and documented interactions between LLMs and tools

Requirements

  • Kubernetes cluster access configured via kubectl

  • Python 3.x

  • MCP framework installed and configured

Security Note

When using this client with LLMs, ensure that:

  • Proper access controls are in place for your Kubernetes cluster

  • The MCP server is running in a secure environment

  • API access is properly authenticated and authorized

Usage with Claude Desktop

{
    "mcpServers": {
        "Kubernetes": {
            "command": "uv",
            "args": [
                "--directory",
                "~/mcp/mcp-k8s-server",
                "run",
                "kubernetes.py"
            ]
        }
    }
}

Contributing

We welcome contributions to the MCP Kubernetes Server! If you'd like to contribute:

  1. Fork the repository

  2. Create a new branch for your feature (git checkout -b feature/amazing-feature)

  3. Make your changes

  4. Write or update tests as needed

  5. Commit your changes (git commit -m 'Add some amazing feature')

  6. Push to your branch (git push origin feature/amazing-feature)

  7. Open a Pull Request

For major changes, please open an issue first to discuss what you would like to change.

Installing via Smithery

To install Kubernetes Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @abhijeetka/mcp-k8s-server --client claude

Available Tools

25 tools
annotate_resourceC

Annotate a Kubernetes resource with the specified annotation

Args:
    resource_type: Type of the resource (e.g., pod, service, deployment)
    resource_name: Name of the resource to annotate
    annotation: Annotation to add (e.g., key=value)
    namespace: Namespace of the resource

Inputs: resource_type (required), resource_name (required), annotation (required), namespace.

create_deploymentB

Create a Kubernetes deployment with specified name, image, namespace and replicas

Inputs: name (required), image (required), namespace, replicas.

delete_resourceB

Delete a Kubernetes resource

Args:
    resource_type: Type of the resource (e.g., pod, service, deployment,configmap,secret,ingress,statefulset,replicaset,damonset,newtorkpolicy,rolebinding,role,serviceaccount,job,cronjob)
    resource_name: Name of the resource to delete
    namespace: Namespace of the resource

Inputs: resource_type (required), resource_name (required), namespace.

describe_podC

Describe a specific pod

Inputs: pod_name (required), namespace.

expose_serviceC

Expose a resource as a new kubernetes service k8s_object can be pod (po), service (svc), replicationcontroller (rc), deployment (deploy), replicaset (rs) Type for this service: ClusterIP, NodePort, LoadBalancer, or ExternalName. Default is 'ClusterIP'.

Inputs: k8s_object (required), name (required), namespace, type, +3 more.

get_cronjobsC

Get all cronjobs in the specified namespace

Inputs: namespace.

get_current_contextB

Get the current Kubernetes context

Inputs: no named parameters.

get_daemonsetsC

Get all daemonsets in the specified namespace

Inputs: namespace.

get_deploymentsC

Get all deployments in the specified namespace

Inputs: namespace.

get_eventsC

Get the events of a specific namespace

Inputs: namespace.

get_failing_podsB

Get all pods with issues in the specified namespace

Inputs: namespace.

get_jobsC

Get all jobs in the specified namespace

Inputs: namespace.

get_logsC

Get the logs of a specific pod

Inputs: name (required), namespace, tail.

get_namespacesB

Get all namespaces in the cluster

Inputs: no named parameters.

get_nodesB

Get all nodes in the cluster

Inputs: no named parameters.

get_podsC

Get all pods in the specified namespace

Inputs: namespace.

get_servicesC

Get all services in the specified namespace

Inputs: namespace.

get_statefulsetsC

Get all statefulsets in the specified namespace

Inputs: namespace.

label_resourceA

Label a Kubernetes resource with the specified label

Args:
    resource_type: Type of the resource (e.g., pod, service, deployment)
    resource_name: Name of the resource to label
    label: Label to add (e.g., key=value)
    namespace: Namespace of the resource

Inputs: resource_type (required), resource_name (required), label (required), namespace.

list_contextsB

List all available Kubernetes contexts

Inputs: no named parameters.

port_forwardC

Port forward a resource to the outside world k8s_object can be a pod, deployment or a service and it should be in the format pod/, deployment/, service/

Inputs: k8s_object (required), name (required), namespace, port, +1 more.

remove_annotationC

Remove an annotation from a Kubernetes resource

Args:
    resource_type: Type of the resource (e.g., pod, service, deployment)
    resource_name: Name of the resource to remove the annotation from
    annotation_key: Key of the annotation to remove
    namespace: Namespace of the resource

Inputs: resource_type (required), resource_name (required), annotation_key (required), namespace.

remove_labelB

Remove a label from a Kubernetes resource

Args:
    resource_type: Type of the resource (e.g., pod, service, deployment)
    resource_name: Name of the resource to remove the label from
    label_key: Key of the label to remove
    namespace: Namespace of the resource

Inputs: resource_type (required), resource_name (required), label_key (required), namespace.

update_deploymentC

Update a Kubernetes deployment with new replicas count and/or image

Args:
    name: Name of the deployment to update
    namespace: Namespace of the deployment
    replicas: New number of replicas (optional)
    image: New container image (optional)

Inputs: name (required), namespace, replicas, image.

use_contextB

Switch to a specific Kubernetes context Args: context_name: The name of the Kubernetes context to switch to

Inputs: context_name (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 25 tools

    Disambiguation4/5

    Most tools have distinct purposes targeting specific Kubernetes resources or operations, with clear boundaries like annotate_resource vs. remove_annotation. However, some overlap exists between get_pods and describe_pod, and expose_service and port_forward could be confused for similar networking tasks, though descriptions help differentiate them.

    Naming Consistency4/5

    The naming follows a consistent verb_noun pattern throughout, such as get_pods, create_deployment, and delete_resource. Minor deviations include describe_pod (singular noun) and expose_service (which could be named create_service for consistency), but overall the pattern is predictable and readable.

    Tool Count3/5

    With 25 tools, the count feels heavy for a Kubernetes server, bordering on excessive. While Kubernetes is a complex domain, this many tools may overwhelm agents and could be streamlined, such as by consolidating get_* tools into a single generic get_resource with parameters.

    Completeness5/5

    The tool set provides comprehensive coverage of Kubernetes operations, including CRUD for deployments, resource management (annotate, label, delete), monitoring (get_logs, get_events), and cluster administration (context switching, namespace listing). No obvious gaps are present for core workflows, ensuring agents can handle most tasks without dead ends.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      A Model Context Protocol server that enables AI assistants to interact with Kubernetes clusters through natural language, supporting core Kubernetes operations, monitoring, security, and diagnostics.
      140 npm
      974
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that enables AI assistants to interact with Kubernetes clusters by translating natural language into kubectl and Helm operations. It allows users to query, manage, and diagnose Kubernetes resources and cluster states through a seamless integration.
      19
      Apache 2.0
    • A
      license
      Not graded
      quality
      Not graded
      maintenance
      A lightweight MCP server that enables natural language interaction with Kubernetes clusters, allowing management of pods, deployments, namespaces, and cluster resources through conversational queries or API endpoints.
      1
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      An Model Context Protocol server that lets language models directly manage and visualize Kubernetes clusters through safe, high-level operational tools.
      1
      -