How to Use Kubernetes MCP Server (K8s MCP)

Simplify K8s management with AI! This tutorial guides you through setting up a Kubernetes MCP Server (K8s MCP) to automate tasks and gain insights. Start managing your cluster smarter today!

Ashley Goolam

Ashley Goolam

23 June 2025

How to Use Kubernetes MCP Server (K8s MCP)

Have you ever found managing your Kubernetes (K8s) deployments to be a challenging task? With the help of AI, you can efficiently manage containers while maintaining control and security. This is where the Kubernetes MCP Server (K8s MCP) comes into play.

This tutorial will guide you through understanding and using a K8s MCP, which is a server implementing the Model Context Protocol (MCP) specifically designed for interacting with your Kubernetes clusters. This unlocks exciting possibilities for automating tasks, gaining insights, and even using AI agents to manage your deployments. Let's dive into the world of intelligent cloud management!

💡
Before you begin configuring the Kubernetes MCP Server, consider exploring Apidog—a powerful tool for designing, testing, and documenting APIs. Apidog simplifies API integration with structured models and seamless collaboration. When combined with Zapier MCP, it enhances automation and API management.
Apidog Ui image
button

What is a Kubernetes MCP Server (K8s MCP)?

A Kubernetes MCP Server is a bridge between your AI-powered tools and your Kubernetes cluster. It implements the Model Context Protocol (MCP) to provide a secure and structured way for AI to interact with your deployments.

Think of it this way: Kubernetes is the operating system for your cloud, and the K8s MCP is the translator that allows AI to understand and manage that operating system.

kubernetes official website

Instead of directly exposing your cluster to potentially untrusted AI models, the K8s MCP server acts as a gatekeeper, providing a controlled interface that allows AI to:

All of this happens with proper authorization and auditing, ensuring that your cluster remains secure.

Kubernetes MCP Server Prerequisites

Before we get started, let's make sure you have everything you need:

1. A Kubernetes Cluster: You'll need access to a running Kubernetes cluster. This could be a local cluster (using Minikube or Rancher Desktop), a cloud-based cluster (on AWS, Azure, or Google Cloud), or any other Kubernetes environment.

2. kubectl Installed and Configured: The kubectl command-line tool is essential for interacting with your Kubernetes cluster.

3. Node.js and Bun: This specific K8s MCP implementation uses Node.js and the Bun package manager. Make sure you have both installed.

bun package installer

4. Helm v3 (Optional): Helm v3 needs to be installed and configured for the server, although it might not be used. You can download it from their official website.

helm
How to Use GPT4Free Python Library
This tutorial will guide you through the installation, setup, and usage of the gpt4free library, showing you how to leverage its capabilities for various AI-powered text generation tasks.

Installation and Configuration: Setting Up Your K8s MCP Server

1. Clone the Repository:

Open your terminal and run the following command:

git clone https://github.com/Flux159/mcp-server-kubernetes.git
cd mcp-server-kubernetes

This will download the code from GitHub and move you into the project directory.

2. Install Dependencies with Bun:

This project utilizes Bun, a fast JavaScript runtime, as its package manager. Make sure you have Bun installed, and then run:

bun install

This command reads the package.json file and installs all the necessary dependencies for the project.

3. Run the K8s MCP Server:

bun run dev # for development and file watching

This will start the K8s MCP server. It will automatically connect to the kubectl context you currently have configured. Make sure your connection to the K8s cluster is working or the server will have connection issues.

Important Notes: Since the server will automatically connect to your current kubectl context you will want to make sure that Helm is properly configured if you have a Helm chart in the project.

4. Local Testing with MCP Inspector:

For quick testing of the k8's MCP server, it is recommended to use the Model Context Protocol Inspector (@modelcontextprotocol/inspector) for local testing. This tool helps you visualize and interact with the MCP server's capabilities.

npx @modelcontextprotocol/inspector node dist/index.js

Follow the on-screen instructions in the terminal to access the Inspector link in your browser. This will allow you to explore the available MCP resources and test commands.

mcp inspector

Local Testing K8s MCP Server with Claude Desktop

To integrate this K8s MCP with Claude Desktop (or another AI tool), you'll need to configure Claude to communicate with the server.

  1. Locate Claude Desktop Configuration:

Find the "claude_desktop_config.json" file in Claude Desktop's settings (usually found in a Developer or Advanced section).

2. Add the MCP Server Configuration:

Add a new entry to the mcp servers section of the "claude_desktop_config.json" file:

{
  "mcpServers": {
    "k8s-mcp": { // Or choose a descriptive name
      "command": "node",
      "args": ["/path/to/your/mcp-server-kubernetes/dist/index.js"]
    }
  }
}

Important: Replace "/path/to/your/mcp-server-kubernetes/dist/index.js" with the actual absolute path to the "dist/index.js" file in your cloned repository.

3. Test with Claude Desktop:

Restart Claude Desktop. Now, you should be able to interact with your Kubernetes cluster through Claude using natural language commands. Start by asking Claude to list your pods or create a test deployment to see if the connection to the server works. If these work, it is safe to assume that the rest will work as well.

Example 1: "Can you list the pods in the default namespace"

list pods

Example 2: "Can you create and nginx pod in the default namespace and name it nginx-pod"

create pods

Example 3: "Can you delete the nginx pod"

delete pods

Security Considerations: Protecting Your Cluster

Security is paramount when integrating AI with your Kubernetes cluster.

Conclusion

You've now taken the first steps towards exploring the possibilities of using AI to interact with your Kubernetes cluster! By setting up a K8s MCP server, you've opened the door for AI tools to potentially assist with management and provide insights. Remember to focus on security and carefully validate the functionality before relying on the AI for critical tasks.

button
Apidog all in one image

Explore more

Cypher Alpha: What's the Free Mysterious OpenRouter API?

Cypher Alpha: What's the Free Mysterious OpenRouter API?

Learn to harness OpenRouter’s free Cypher Alpha AI model with Apidog for efficient API testing. This guide covers setup, examples, and benefits for developers.

2 July 2025

How to Find the API of a Website with AI

How to Find the API of a Website with AI

Discover how to find website APIs using Hyperbrowser’s AI or Developer Tools. This guide covers setup, scanning with AI, and manual methods for sites like retouched.ai!

2 July 2025

What is Claude Code Hooks and How to Use It

What is Claude Code Hooks and How to Use It

For Vibe Coders, tools like Anthropic's Claude Code are transforming how developers write, debug, and manage their projects. Claude Code acts as an "agentic coding tool" that lives in your terminal, capable of understanding your entire codebase, interacting with your file system, running commands, and even browsing the web for documentation. It excels at tasks like writing new features, fixing bugs, and refactoring code through natural language prompts. However, a core characteristic of Large L

2 July 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs