Skip to content

About

MCP server for Operator SDK - enables AI assistants to build Kubernetes operators

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Operator SDK MCP Server

A Model Context Protocol (MCP) server that enables AI assistants to interact with the Operator SDK for Kubernetes operator development.

This server exposes operator-sdk commands as MCP tools, allowing you to build, test, and manage Kubernetes operators through natural language conversations with AI assistants.

Why This Exists

The Operator SDK is powerful but has many commands with complex flags. This MCP server lets you:

  • Ask AI to scaffold operators instead of remembering operator-sdk init flags
  • Generate APIs naturally - "Create a Database API for group cache.example.com v1alpha1"
  • Get help with bundles - AI validates, explains errors, and fixes issues
  • Test with scorecard - AI interprets results and suggests fixes
  • Learn operator development - AI guides you through the workflow

Features

  • Project Initialization: Scaffold new Go, Ansible, or Helm operators
  • API Management: Create APIs, controllers, and webhooks
  • Bundle Operations: Generate and validate OLM bundles
  • Testing: Run scorecard tests and validation
  • OLM Integration: Local operator installation with run bundle
  • Safety First: Read-only mode by default prevents accidental changes
  • Modular: Enable only the toolsets you need

Prerequisites

  • Go 1.23+ - Install Go
  • operator-sdk - Install operator-sdk
  • MCP Client - Any MCP-compatible client (e.g., Claude Desktop, Continue, etc.)
  • (Optional) Kubernetes cluster with OLM - For run_bundle operations

Verify operator-sdk is installed:

operator-sdk version

Installation

Option 1: Build from Source

git clone https://github.com/operator-framework/operator-sdk-mcp-server.git
cd operator-sdk-mcp-server
make build

The binary will be created at bin/operator-sdk-mcp-server.

Option 2: Install to GOPATH

git clone https://github.com/operator-framework/operator-sdk-mcp-server.git
cd operator-sdk-mcp-server
make install

This installs the binary to $GOPATH/bin/operator-sdk-mcp-server.

Configuration

MCP Client Integration

Claude Desktop

Add this to your configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "operator-sdk": {
      "command": "/absolute/path/to/operator-sdk-mcp-server",
      "args": [
        "--read-only=false",
        "--working-dir=/path/to/your/operator"
      ]
    }
  }
}

Important: Use absolute paths! Example:

{
  "mcpServers": {
    "operator-sdk": {
      "command": "/Users/yourname/go/bin/operator-sdk-mcp-server",
      "args": [
        "--read-only=false",
        "--working-dir=/Users/yourname/projects/my-operator"
      ]
    }
  }
}

Other MCP Clients

For other MCP-compatible clients, configure the server with:

  • Command: Path to operator-sdk-mcp-server binary
  • Transport: stdio (default)
  • Arguments: See Configuration Options below

Configuration Options

Flag Default Description
--working-dir . Working directory for operator-sdk commands
--read-only true Prevents write operations (create, modify, delete)
--toolsets init,api,bundle,scorecard,run Comma-separated list of enabled toolsets

Available Toolsets

  • init: Project initialization (init_operator, init_go, init_ansible, init_helm)
  • api: API and webhook management (create_api, create_webhook)
  • bundle: Bundle operations (generate_bundle, validate_bundle, generate_kustomize)
  • scorecard: Testing (run_scorecard)
  • run: OLM integration (run_bundle, cleanup_bundle)

Quick Start

  1. Build and install the MCP server (see Installation above)

  2. Configure your MCP client with the server (restart client after editing config)

  3. Ask your AI assistant to help you build an operator:

    You: Initialize a new Go operator for github.com/example/memcached-operator
         with domain example.com
    
    AI: [Uses init_go tool] ✓ Created operator project!
    
    You: Create an API for Memcached with group cache, version v1alpha1
    
    AI: [Uses create_api tool] ✓ Created API and controller!
    
    You: Generate an OLM bundle for version 0.1.0
    
    AI: [Uses generate_bundle tool] ✓ Bundle created at ./bundle!
    
    You: Validate the bundle
    
    AI: [Uses validate_bundle tool] ✓ Bundle is valid!
    

Available Tools

The server exposes 12 MCP tools:

Project Initialization

  • init_operator - Initialize a new operator project (Go, Ansible, or Helm)
  • init_go - Initialize Go operator project
  • init_ansible - Initialize Ansible operator project
  • init_helm - Initialize Helm operator project

API & Webhook Management

  • create_api - Create a new API and controller
  • create_webhook - Create admission webhooks (validating, mutating, conversion)

Bundle Operations

  • generate_bundle - Generate OLM bundle manifests
  • validate_bundle - Validate bundle format and content
  • generate_kustomize - Run make generate and make manifests

Testing

  • run_scorecard - Execute operator scorecard tests

OLM Integration

  • run_bundle - Install operator using OLM
  • cleanup_bundle - Remove operator installation

See USAGE.md for detailed usage examples and workflows.

Example Workflows

Create a New Operator

User: Create a new Go operator for managing databases

AI will:
1. Ask for domain and repo details
2. Run init_go to scaffold the project
3. Guide you through next steps

Add an API

User: Add an API for a Database resource in the storage group v1alpha1

AI will:
1. Run create_api with the correct parameters
2. Show you the generated files
3. Explain what to do next

Bundle and Validate

User: Generate and validate my OLM bundle for version 0.1.0

AI will:
1. Run generate_bundle
2. Run validate_bundle
3. Report any issues and suggest fixes

Safety Features

  • Read-only mode by default: Prevents accidental modifications
  • Input validation: Validates parameters before execution
  • Error handling: Clear error messages from operator-sdk
  • Modular toolsets: Enable only what you need

Development

# Format code
make fmt

# Tidy dependencies
make tidy

# Development build (fmt + tidy + build)
make dev-build

# Clean build artifacts
make clean

Troubleshooting

"operator-sdk not found"

Install operator-sdk: https://sdk.operatorframework.io/docs/installation/

"operation not allowed in read-only mode"

Set --read-only=false in your MCP client config

"Binary not found"

Use absolute paths in your MCP client config, not relative paths

AI doesn't see the tools

  1. Check the config file path is correct for your OS
  2. Restart your MCP client after editing config
  3. Check MCP client logs for errors

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

Related Projects

License

Apache License 2.0 - See LICENSE file for details.

Copyright 2026 The Operator Framework Authors

About

MCP server for Operator SDK - enables AI assistants to build Kubernetes operators

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages