KubeSphere MCP server

Integrates with KubeSphere APIs to enable management of Kubernetes clusters, workspaces, users, and extensions through natural language commands without navigating the web console.
Back to servers
Setup instructions
Provider
KubeSphere
Release date
Apr 29, 2025
Language
Go
Stats
11 stars

The KubeSphere MCP Server implements the Model Context Protocol (MCP) to interact with KubeSphere APIs, allowing AI agents to retrieve and manage resources from KubeSphere. It provides functionality across four main areas: Workspace Management, Cluster Management, User and Roles, and Extensions Center.

Prerequisites

Before installing the KubeSphere MCP Server, you need:

  • A running KubeSphere cluster
  • Access address for your KubeSphere instance
  • Valid username and password for authentication

Installation

Setting Up KSConfig

First, you need to create a KSConfig file that contains connection information for your KubeSphere cluster. This configuration is similar to kubeconfig in format.

Create a file with the following structure:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: <CA file>
    server: <Server Address>
  name: kubesphere
contexts:
- context:
    cluster: kubesphere
    user: admin
  name: kubesphere
current-context: kubesphere
kind: Config
preferences: {}
users:
- name: admin
  user:
    username: <KubeSphere Username>
    password: <KubeSphere Password>

Replace the placeholders with your specific information:

  • <CA file>: (Optional) Base64-encoded CA certificate for HTTPS connections
  • <Server Address>: (Required) An HTTPS address for your KubeSphere server
  • <KubeSphere Username>: (Required) Your KubeSphere user account
  • <KubeSphere Password>: (Required) Password for your KubeSphere account

Note: The default context name is kubesphere, which can be changed using the environment variable KUBESPHERE_CONTEXT.

Installing the MCP Server

You can obtain the ks-mcp-server binary in one of two ways:

  1. Build from source:
go build -o ks-mcp-server cmd/main.go
  1. Download a pre-built binary from the GitHub releases page

After obtaining the binary, move it to a directory in your system PATH:

mv ks-mcp-server /usr/local/bin/

Using with AI Agents

Claude Desktop Configuration

To use the KubeSphere MCP Server with Claude Desktop:

  1. Update your MCP configuration in Claude Desktop settings:
{
  "mcpServers": {
    "KubeSphere": {
      "args": [
        "stdio",
        "--ksconfig", "<ksconfig file absolute path>",
        "--ks-apiserver", "<KubeSphere Address>"
      ],
      "command": "ks-mcp-server"
    }
  }
}

Replace the placeholders:

  • <ksconfig file absolute path>: The full path to your ksconfig file
  • <KubeSphere Address>: (Optional but required for HTTP access) The address of your KubeSphere cluster (e.g., http://172.10.0.1:30880)

Cursor Configuration

To use the KubeSphere MCP Server with Cursor:

  1. Update your MCP configuration in Cursor settings:
{
  "mcpServers": {
    "KubeSphere": {
      "args": [
        "stdio",
        "--ksconfig", "<ksconfig file absolute path>",
        "--ks-apiserver", "<KubeSphere Address>"
      ],
      "command": "ks-mcp-server"
    }
  }
}

Replace the placeholders as described in the Claude Desktop configuration.

Usage Examples

After configuration, you can interact with your KubeSphere cluster by asking the AI agent questions related to:

  • Workspace Management
  • Cluster Management
  • User and Roles
  • Extensions Center

For example, you might ask:

  • "Show me the workspaces in my KubeSphere cluster"
  • "List the users with administrator privileges"
  • "What extensions are installed in my KubeSphere instance?"

The AI agent will use the MCP server to query KubeSphere and provide the requested information.

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 "KubeSphere" '{"command":"ks-mcp-server","args":["stdio","--ksconfig","<ksconfig file absolute path>","--ks-apiserver","<KubeSphere Address>"]}'

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": {
        "KubeSphere": {
            "command": "ks-mcp-server",
            "args": [
                "stdio",
                "--ksconfig",
                "<ksconfig file absolute path>",
                "--ks-apiserver",
                "<KubeSphere Address>"
            ]
        }
    }
}

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": {
        "KubeSphere": {
            "command": "ks-mcp-server",
            "args": [
                "stdio",
                "--ksconfig",
                "<ksconfig file absolute path>",
                "--ks-apiserver",
                "<KubeSphere Address>"
            ]
        }
    }
}

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