New: K8sGPT works with Claude Desktop!

Back to Documentation

MCP Server

Reference for the Model Communication Protocol (MCP) server in K8sGPT

Overview

The MCP (Model Communication Protocol) server is a new feature in K8sGPT that enables advanced, real-time, and programmatic interaction with the analysis engine. It is designed for integration scenarios where you want to communicate with K8sGPT over a persistent connection.

Getting Started

Prerequisites

  • K8sGPT v0.4.14 or later
  • A client capable of communicating over stdio using the MCP protocol

Starting the MCP Server

k8sgpt serve mcp

Protocol Overview

The MCP protocol uses JSON messages exchanged over standard input and output. Each message includes a type field and a payload field.

Example Request

{
  "type": "analyze",
  "payload": {
    "namespace": "default",
    "filters": ["Pod", "Deployment"]
  }
}

Example Response

{
  "type": "analyzeResult",
  "payload": {
    "issues": [
      {
        "resource": "pod/my-app-123",
        "problem": "CrashLoopBackOff",
        "explanation": "The pod is crashing due to ...",
        "suggestion": "Check the container logs for errors."
      }
    ]
  }
}

Supported Commands

  • analyze: Triggers an analysis of the cluster or a specific namespace
  • status: Returns the current status of the server
  • shutdown: Gracefully terminates the MCP server

Integration with Claude Desktop

K8sGPT can be integrated with Claude Desktop to provide AI-powered Kubernetes cluster analysis via the MCP protocol. This integration enables:

  • Real-time cluster analysis through Claude Desktop
  • Natural language interaction with your Kubernetes clusters
  • Enhanced troubleshooting capabilities

Configuration

Configure the MCP server using standard K8sGPT configuration mechanisms. Key settings include:

  • Concurrency limits for request handling
  • Connection timeouts and keep-alive settings
  • Protocol-specific options

Troubleshooting

  • Ensure your client is correctly communicating over stdio
  • Validate that your JSON messages conform to the expected schema
  • Check for any interference with input/output streams