# rohitg00/kubectl-mcp-server architecture

> Architecture diagram of the GitHub repository rohitg00/kubectl-mcp-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rohitg00/kubectl-mcp-server
- Repository: https://github.com/rohitg00/kubectl-mcp-server

## Overview

##### Project Type and Purpose
- This project is a tool designed to integrate Kubernetes operations with AI assistants using the Model Context Protocol (MCP). It functions in two modes—CLI for direct command-line execution and Server mode for handling MCP requests from assistants like Claude, Cursor, and Windsurf.
- The tool exposes core Kubernetes operations (like pod management, logs, deployments, scaling, etc.), enhanced by natural language processing, monitoring, security, and diagnostics capabilities.

##### File Structure
- The top-level “kubectl_mcp_tool” directory represents the main package and contains modules such as CLI, core operations (e.g., mcp_server.py, mcp_kubectl_tool.py), natural language processing, diagnostics, security, monitoring, and utility functions.
- The “compatible_servers” directory holds various server implementations (for Cursor, Windsurf, generic, and a minimal version), which shows support for multiple integration environments.
- The “docs” directory and related integration documentation for each AI assistant illustrate the project’s emphasis on providing plug-and-play support for external tools.
- There’s also a “python_tests” suite for validating functionalities, highlighting a well-tested and modular design.
- Configuration scripts (install.sh, start_mcp_server.sh) and setup scripts (setup.py, requirements.txt) are included to assist deployment and development.

##### Extract Key Architectural Components from the README
- The README describes several main components:
– MCP Server: The core server that processes commands from MCP clients.
– Tools Registry: A mapping of Kubernetes operations into MCP “tools” using registered schemas.
– Transport Layer: Supports multiple transport protocols (stdio, SSE, HTTP) for communication.
– Core Operations: The component that translates natural language or MCP tool calls into actual Kubernetes API interactions.
– Response Formatter: Converts responses from Kubernetes back into MCP-compliant formats.
- It also outlines the dual mode operation: CLI Mode and Server Mode.
- Documentation details the integration with specific AI assistants by providing sample configuration files (with minimal_wrapper, for example) for Claude, Cursor, and Windsurf.

##### Elements to Incorporate
- Clear labels for each of the following:
– MCP Server
– Tools Registry
– Transport Layer (with sub-labels for stdio, SSE, HTTP)
– Core Operations (interface with Kubernetes API)
– Response Formatter
– CLI Mode
– Compatible Servers (Cursor, WindSurf, Generic, Minimal)
– Kubernetes Cluster (as an external component)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients
    subgraph "External Clients"
        Claude["Claude (AI Assistant)"]:::external
        Cursor["Cursor (AI Assistant)"]:::external
        Windsurf["Windsurf (AI Assistant)"]:::external
        CLITerminal["CLI Terminal"]:::external
    end

    %% Compatible Servers
    subgraph "Compatible Servers"
        CursorCompat["Cursor Compatible Server"]:::transport
        GenericCompat["Generic Compatible Server"]:::transport
        MinimalCompat["Minimal Compatible Server"]:::transport
        WindsurfCompat["Windsurf Compatible Server"]:::transport
    end

    %% Main Server Pipeline
    MCPServer["MCP Server"]:::server
    Transport["Transport Layer (stdio/SSE/HTTP)"]:::transport
    ToolsRegistry["Tools Registry"]:::server
    CoreOps["Core Kubernetes Operations"]:::operations
    ResponseFmt["Response Formatter"]:::operations
    CLIInterface["CLI Interface"]:::server
    K8sCluster["Kubernetes Cluster"]:::cluster

    %% Additional Components
    NLP["Natural Language Processing"]:::additional
    Diagnostics["Diagnostics"]:::additional
    SecurityOps["Security Ops"]:::additional
    TestSuite["Testing Suite"]:::tests

    %% Connections from External Clients to MCP Server and CLI Interface
    Claude -->|"sends request"| MCPServer
    Cursor -->|"sends request"| MCPServer
    Windsurf -->|"sends request"| MCPServer
    CLITerminal -->|"executes"| CLIInterface

    %% Connections from Compatible Servers to MCP Server
    CursorCompat -->|"routes request"| MCPServer
    GenericCompat -->|"routes request"| MCPServer
    MinimalCompat -->|"routes request"| MCPServer
    WindsurfCompat -->|"routes request"| MCPServer

    %% Main server processing flow (MCP mode)
    MCPServer -->|"forwards"| Transport
    Transport -->|"maps to"| ToolsRegistry
    ToolsRegistry -->|"invokes"| CoreOps
    CoreOps -->|"processes and formats"| ResponseFmt
    ResponseFmt -->|"communicates with"| K8sCluster

    %% CLI mode flow
    CLIInterface -->|"direct call"| CoreOps

    %% Integration of additional functionalities
    CoreOps -.->|"uses"| NLP
    CoreOps -.->|"monitors"| Diagnostics
    CoreOps -.->|"secures"| SecurityOps

    %% Testing integration (dotted lines)
    MCPServer -.-> TestSuite
    ToolsRegistry -.-> TestSuite
    CLIInterface -.-> TestSuite
    CoreOps -.-> TestSuite

    %% Styling
    classDef external fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef server fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef transport fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef operations fill:#FFB6C1,stroke:#000,stroke-width:1px;
    classDef additional fill:#D3D3D3,stroke:#000,stroke-width:1px;
    classDef tests fill:#AFEEEE,stroke:#000,stroke-width:1px;
    classDef cluster fill:#FFE4B5,stroke:#000,stroke-width:1px;

    %% Click Events
    click MCPServer "https://github.com/rohitg00/kubectl-mcp-server/blob/main/kubectl_mcp_tool/core/mcp_server.py"
    click MCPServer "https://github.com/rohitg00/kubectl-mcp-server/blob/main/kubectl_mcp_tool/mcp_server.py"
    click ToolsRegistry "https://github.com/rohitg00/kubectl-mcp-server/blob/main/kubectl_mcp_tool/mcp_kubectl_tool.py"
    click CLIInterface "https://github.com/rohitg00/kubectl-mcp-server/blob/main/kubectl_mcp_tool/cli.py"
    click CLIInterface "https://github.com/rohitg00/kubectl-mcp-server/blob/main/kubectl_mcp_tool/cli/__main__.py"
    click CursorCompat "https://github.com/rohitg00/kubectl-mcp-server/blob/main/compatible_servers/cursor/cursor_compatible_mcp_server.py"
    click GenericCompat "https://github.com/rohitg00/kubectl-mcp-server/blob/main/compatible_servers/generic/kubectl_mcp_server.py"
    click MinimalCompat "https://github.com/rohitg00/kubectl-mcp-server/blob/main/compatible_servers/minimal/minimal_mcp_server.py"
    click WindsurfCompat "https://github.com/rohitg00/kubectl-mcp-server/blob/main/compatible_servers/windsurf/windsurf_compatible_mcp_server.py"
    click CoreOps "https://github.com/rohitg00/kubectl-mcp-server/blob/main/kubectl_mcp_tool/core/kubernetes_ops.py"
    click NLP "https://github.com/rohitg00/kubectl-mcp-server/blob/main/kubectl_mcp_tool/natural_language.py"
    click NLP "https://github.com/rohitg00/kubectl-mcp-server/blob/main/kubectl_mcp_tool/utils/natural_language.py"
    click Diagnostics "https://github.com/rohitg00/kubectl-mcp-server/blob/main/kubectl_mcp_tool/diagnostics.py"
    click Diagnostics "https://github.com/rohitg00/kubectl-mcp-server/blob/main/kubectl_mcp_tool/monitoring/diagnostics.py"
    click SecurityOps "https://github.com/rohitg00/kubectl-mcp-server/blob/main/kubectl_mcp_tool/security/security_ops.py"
    click TestSuite "https://github.com/rohitg00/kubectl-mcp-server/tree/main/python_tests"
```
