Skip to main content
Glama

k8s-docs-mcp ☸️

License Python MCP Kubernetes

Official Kubernetes Documentation & Canonical YAML Manifest Assistant for Autonomous AI Agents via the Model Context Protocol (MCP).

k8s-docs-mcp connects your AI coding assistant (Cursor, Claude Desktop, Antigravity, VS Code) directly to the upstream source of truth: github.com/kubernetes/website.


💡 The Problem: LLM "Version Blindness" & Hallucinations

General-purpose Large Language Models regularly fail when generating Kubernetes configurations because their training sets mix documentation across outdated releases:

  • ❌ Deprecated APIs: Emitting apiVersion: extensions/v1beta1 for Ingress instead of networking.k8s.io/v1.

  • ❌ Removed Features: Suggesting PodSecurityPolicy (removed in K8s 1.25) instead of modern PodSecurityStandards or in-tree CEL ValidatingAdmissionPolicy.

  • ❌ Formatting Corruption: Mangling YAML indentation, missing mandatory spec fields, or hallucinating non-existent controller flags.

k8s-docs-mcp solves this deterministically:

  1. Canonical YAML Manifest Extraction: Extracts exact, verified YAML manifests directly from upstream Kubernetes documentation and examples in < 20 ms, completely bypassing generative LLM mutation.

  2. Current Upstream Documentation: Delivers authoritative explanations with exact links to https://kubernetes.io/docs/....

  3. Continuous Upstream Synchronization: Pulls weekly updates directly from kubernetes/website (content/en/docs and content/en/examples) using sparse git checkouts to stay aligned with current Kubernetes releases.


Related MCP server: Kube MCP

🏛️ The Cloud Native Agent Trifecta

k8s-docs-mcp works as an independent standalone tool or as the authoritative documentation engine paired with syllabus guides and architectural tutors:

flowchart TD
    IDE["AI Coding Assistant / Agent\n(Claude Desktop, Cursor, Antigravity)"]
    
    IDE -->|"MCP 1: Syllabus & Learning Paths"| S["study-cybercirujas\n(Official CKA/CKS/CNPE Exam Objectives)"]
    IDE -->|"MCP 2: Canonical Docs & Syntax"| K["k8s-docs-mcp\n(Authoritative kubernetes.io Docs & Verified YAMLs)"]
    IDE -->|"MCP 3: In-Depth Architecture"| R["rag-tutor\n(Engineering Books & GraphRAG Platform Patterns)"]
    
    style K fill:#326CE5,stroke:#fff,stroke-width:2px,color:#fff

🛠️ Available MCP Tools

Tool Name

Parameters

Description

search_k8s_docs

query: str, limit: int = 3

Performs high-speed BM25 search over official Kubernetes documentation via SQLite FTS5. Returns authoritative excerpts and official https://kubernetes.io/docs/... URLs.

get_canonical_manifest

kind: str

Retrieves verified, unaltered Kubernetes YAML manifests directly from official examples for any resource Kind (NetworkPolicy, ValidatingAdmissionPolicy, Deployment, ValidatingWebhookConfiguration, etc.). Inlines Hugo {{< codenew >}} files automatically.

check_api_version

kind: str, api_version: Optional[str]

Deterministically verifies API version validity, deprecation status, and removal history using the official Kubernetes OpenAPI registry.

list_supported_resources

None

Lists all Kubernetes API resource Kinds currently indexed with canonical YAML manifests.

sync_upstream_docs

None

Fetches or updates documentation and examples from github.com/kubernetes/website and rebuilds the local SQLite FTS5 index.


🚀 Quickstart & MCP Configuration

1. Claude Desktop

Add k8s-docs-mcp to your claude_desktop_config.json:

{
  "mcpServers": {
    "k8s-docs": {
      "command": "uvx",
      "args": ["k8s-docs-mcp"]
    }
  }
}

Or for a local development clone:

{
  "mcpServers": {
    "k8s-docs": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/k8s-docs-mcp",
        "run",
        "k8s-docs-mcp"
      ]
    }
  }
}

2. Cursor IDE

In your project root, add to .cursor/mcp.json:

{
  "mcpServers": {
    "k8s-docs": {
      "command": "uvx",
      "args": ["k8s-docs-mcp"]
    }
  }
}

3. Local Development & Testing

# Clone the repository
git clone https://github.com/villadalmine/k8s-docs-mcp.git
cd k8s-docs-mcp

# Install dependencies using uv
uv sync

# Run test suite
uv run pytest tests/

# Execute interactive tool verification
uv run python -c "
from k8s_docs_mcp.server import search_k8s_docs, get_canonical_manifest

print(search_k8s_docs('validating admission policy'))
print('---')
print(get_canonical_manifest('NetworkPolicy'))
"

🔄 Automated Upstream Synchronization

k8s-docs-mcp uses a lightweight sparse checkout mechanism:

# Pulls only Markdown documentation and YAML examples (~25 MB instead of a 2 GB full clone)
uv run python -c "from k8s_docs_mcp.server import sync_upstream_docs; print(sync_upstream_docs())"

The repository includes a scheduled GitHub Action (.github/workflows/sync-upstream.yml) that runs weekly to verify and update indexed Kubernetes documentation against the latest kubernetes/website main branch.


📜 Intellectual Property & Fair Use

  • All documentation and manifest examples retrieved from kubernetes/website are licensed by the Kubernetes Authors under Apache License 2.0 and Creative Commons Attribution 4.0 International (CC-BY-4.0).

  • k8s-docs-mcp attributes all excerpts directly to their canonical origin on kubernetes.io.

  • This project software is open-source under the Apache License 2.0. See LICENSE for details.

Available Tools

5 tools
check_api_versionB

Verifies Kubernetes API version compatibility, deprecations, and removals deterministically via OpenAPI registry.

Args:
    kind: The Kubernetes resource Kind (e.g. 'Ingress', 'PodSecurityPolicy', 'CronJob', 'ValidatingAdmissionPolicy').
    api_version: Optional apiVersion to test (e.g. 'extensions/v1beta1', 'networking.k8s.io/v1').

Returns:
    Authoritative validation report with current stable apiVersion, deprecation notices, and migration advice.

Inputs: kind (required), api_version. Returns: result

get_canonical_manifestA

Retrieves verified, unaltered Kubernetes YAML manifests directly from official kubernetes.io examples.

Bypasses LLM generative alterations to prevent indentation errors, invalid fields, or deprecated apiVersions.

Args:
    kind: The Kubernetes resource kind (e.g. 'NetworkPolicy', 'Deployment', 'ValidatingAdmissionPolicy', 'ValidatingWebhookConfiguration').

Returns:
    Exact canonical YAML manifests with source file provenance.

Inputs: kind (required). Returns: result

list_supported_resourcesA

Lists all Kubernetes API resource Kinds currently indexed with canonical YAML manifests.

Inputs: no named parameters. Returns: result

search_k8s_docsA

Searches official Kubernetes documentation (kubernetes.io) for concepts, policies, and architectures.

Args:
    query: Search keywords or question (e.g., 'network policies ingress rules', 'validating admission webhook cel').
    limit: Maximum number of documentation sections to return (default: 3).

Returns:
    Authoritative documentation sections with official kubernetes.io URLs.

Inputs: query (required), limit. Returns: result

sync_upstream_docsB

Fetches or updates the latest official documentation and examples from github.com/kubernetes/website.

Preprocesses Hugo shortcodes (resolving {{< codenew >}} into inline YAML) and rebuilds the SQLite FTS5 database.

Inputs: no named parameters. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool has a clearly distinct role: listing indexed kinds, searching official docs, retrieving canonical manifests, checking API version compatibility, and syncing upstream docs. Overlap is minimal, so an agent can reliably select the right tool.

    Naming Consistency5/5

    All tool names use consistent snake_case with a verb-first pattern: list_supported_resources, search_k8s_docs, get_canonical_manifest, check_api_version, sync_upstream_docs. The style is predictable and readable throughout.

    Tool Count5/5

    Five tools is well-scoped for a Kubernetes documentation and manifest helper. Each tool covers a distinct operation, and none feels redundant or unnecessary.

    Completeness4/5

    The surface covers discovery, documentation search, canonical manifest retrieval, API version validation, and upstream syncing. Minor gaps remain, such as validating arbitrary user-supplied YAML or browsing doc sections by category, but core workflows are supported.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      A version-aware Kubernetes documentation assistant that connects LLMs to trusted, real-time Kubernetes docs to reduce hallucinations and ensure accurate, version-specific responses.
      2
      50 npm
      4
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to interact with and manage Kubernetes clusters, supporting operations on pods, deployments, services, configmaps, secrets, namespaces, metrics, and events with built-in safety features for destructive actions.
      9
      7 npm
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Provides AI assistants with tools to access Kubernetes enhancement proposals (KEPs), contributor guidelines, and official documentation via the Model Context Protocol.
      7
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI assistants to search API documentation, retrieve endpoint details, get SDK snippets, and check changelogs from an OpenAPI spec.
      7
      506 npm
      3
      MIT