Files
k8sgpt/pkg/server
Anas Khan 492af39e14 test: assert Serve error synchronously after shutdown in TestServe (#1687)
TestServe started the server in a goroutine that captured Serve's
return value, slept two seconds, then called assert.NoError on it. The
test body returned immediately after Shutdown without ever joining that
goroutine, so the assertion ran after the test had already been recorded
as passed and could never affect its result (a dead assertion). It was
also wrong: closing the listener in Shutdown makes Serve return a
net.ErrClosed error, not nil.

Capture Serve's error over a buffered channel and assert it synchronously
in the test body after Shutdown, checking it wraps net.ErrClosed so the
check actually runs within the test's lifetime and catches an unexpected
Serve failure.

Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Co-authored-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>
2026-07-15 07:07:10 +00:00
..
2025-04-29 09:22:44 +01:00
2025-04-29 09:22:44 +01:00
2025-12-18 13:11:10 +00:00
2025-12-18 13:11:10 +00:00
2025-04-29 09:22:44 +01:00

K8sGPT MCP Server

This directory contains the implementation of the Mission Control Protocol (MCP) server for K8sGPT. The MCP server allows K8sGPT to be integrated with other tools that support the MCP protocol.

Components

  • mcp.go: The main MCP server implementation
  • server.go: The HTTP server implementation
  • tools.go: Tool definitions for the MCP server

Features

The MCP server provides the following features:

  1. Analyze Kubernetes Resources: Analyze Kubernetes resources in a cluster
  2. Get Cluster Information: Retrieve information about the Kubernetes cluster

Usage

To use the MCP server, you need to:

  1. Initialize the MCP server with a Kubernetes client
  2. Start the server
  3. Connect to the server using an MCP client

Example:

client, err := kubernetes.NewForConfig(config)
if err != nil {
    log.Fatalf("Failed to create Kubernetes client: %v", err)
}

mcpServer := server.NewMCPServer(client)
if err := mcpServer.Start(); err != nil {
    log.Fatalf("Failed to start MCP server: %v", err)
}

Integration

The MCP server can be integrated with other tools that support the MCP protocol, such as:

  • Mission Control
  • Other MCP-compatible tools

License

This code is licensed under the Apache License 2.0.