Kubernetes MCP server

Bridges natural language interactions with Kubernetes clusters by wrapping kubectl commands, enabling conversational management of pods, deployments, contexts, and troubleshooting without requiring exact syntax knowledge.
Back to servers
Setup instructions
Provider
Abhijeet Kamble
Release date
Mar 16, 2025
Language
Python
Stats
8 stars

The MCP Kubernetes Server provides a convenient interface for managing Kubernetes clusters through language models. It enables you to perform common Kubernetes operations using natural language interactions, making cluster management more accessible and user-friendly.

Installation

Prerequisites

  • Kubernetes cluster access configured via kubectl
  • Python 3.x
  • MCP framework

Installing via Smithery

The easiest way to install the MCP Kubernetes Server is through Smithery:

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

Configuration

Setting Up with Claude Desktop

To configure the MCP Kubernetes Server for use with Claude Desktop, add the following configuration:

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

Usage

The MCP Kubernetes Server enables you to manage your Kubernetes resources through natural language commands. Here are some examples of operations you can perform:

Resource Management

  • Create deployments with specific configurations
  • Update deployments to different versions
  • Scale deployments to adjust replica count
  • List resources across different namespaces

Examples of Supported Commands

  • Creating resources: "Create a new deployment for me with name nginx-app and image nginx:latest in the production namespace with 3 replicas."
  • Updating resources: "Update the deployment nginx-app to version 1.19 in the production namespace."
  • Scaling resources: "Scale the deployment nginx-app to 5 replicas in the production namespace."
  • Viewing resources: "Get me the pods in the production namespace."

Cluster Management

  • List and switch between contexts
  • View cluster-wide resources
  • Manage namespaces
  • View logs and events

Examples of Context Commands

  • "What is the current context."
  • "List all contexts."
  • "Switch to context my-cluster-context."

Resource Manipulation

  • Add or remove annotations
  • Add or remove labels
  • Expose deployments
  • Port forwarding
  • Delete resources

Examples of Advanced Commands

  • "Get me the logs of pod nginx-pod-123 in the production namespace."
  • "Annotate pod nginx-pod with key1=value1 in the production namespace."
  • "Expose deployment nginx-app in the production namespace on port 80."
  • "Port-forward deployment nginx-app in the production namespace to local port 8080."

Security Considerations

When using the MCP Kubernetes Server with language models, ensure:

  • Proper access controls are configured for your Kubernetes cluster
  • The MCP server runs in a secure environment
  • API access is properly authenticated and authorized

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

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

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

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

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

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

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later