Skip to main content

mcp-server-k8s: A Kubernetes MCP Server

The Model Context Protocol (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. Whether you're building an AI-powered IDE, enhancing a chat interface, or creating custom AI workflows, MCP provides a standardized way to connect LLMs with the context they need.

This repository is an example of how to create an MCP server for managing Kubernetes resources.

Overview

A Model Context Protocol server for interacting with Kubernetes clusters. It provides tools for creating, reading, updating, and deleting Kubernetes resources, as well as observability features like log retrieval and resource inspection.

Components

Tools

The server implements the following tools:

Resource Management

  • get_resources: Retrieve Kubernetes resources

    • Takes resource_type (pod, deployment, service, job), namespace (default: "default"), and optional name
    • Returns JSON-formatted resource information
  • create_resource: Create new Kubernetes resources

    • Takes resource_type, namespace, and manifest (JSON string)
    • Creates the specified resource in the cluster
  • delete_resource: Remove Kubernetes resources

    • Takes resource_type, name, and namespace (default: "default")
    • Deletes the specified resource

Observability

  • get_pod_logs: Retrieve container logs

    • Takes pod_name, namespace (default: "default"), optional container, and tail_lines (default: 100)
    • Returns pod logs
  • describe_resource: Get detailed resource information

    • Takes resource_type, name, and namespace (default: "default")
    • Returns detailed JSON description of the resource
  • get_namespaces: List all namespaces

    • Returns JSON array of namespace information

Advanced Features

  • apply_manifest_from_url: Apply Kubernetes manifests from URLs
    • Takes url and optional namespace (default: "default")
    • Downloads and applies the manifest file

Configuration

The server automatically configures Kubernetes client using:

  1. In-cluster configuration (when running inside Kubernetes)
  2. Local kubeconfig file (when running locally)

Quickstart

Claude Desktop

On MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json On Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "kubernetes": {
    "command": "uvx",
    "args": [
      "mcp-server-k8s"
    ]
  }
}

Development

Building and Publishing

To prepare the package for distribution:

  1. Sync dependencies and update lockfile:
uv sync
  1. Build package distributions:
uv build

This will create source and wheel distributions in the dist/ directory.

  1. Publish to PyPI:
uv publish

Note: You'll need to set PyPI credentials via environment variables or command flags:

  • Token: --token or UV_PUBLISH_TOKEN
  • Or username/password: --username/UV_PUBLISH_USERNAME and --password/UV_PUBLISH_PASSWORD

Debugging

Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the MCP Inspector.

You can launch the MCP Inspector via npm with this command:

npx @modelcontextprotocol/inspector uv --directory $(PWD) run mcp-server-k8s

Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.

Metadata

Release files for mcp-server-k8s 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-server-k8s 0.1.2
File Size Uploaded Provenance
mcp_server_k8s-0.1.2.tar.gz 14.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-server-k8s 0.1.2
File Interpreter ABI Platform
mcp_server_k8s-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 19.4 kB

Release files / mcp_server_k8s-0.1.2.tar.gz

Download URL mcp_server_k8s-0.1.2.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b54be572842458c925fb7b43d40fb5943206f7a96c81ed2d845dbb7dfa5272a3
BLAKE2b-256 checksum
How to use checksums
ae57c171a98a2e85e2dfc188c35c9a3264c6b8d099c416fb2f96782b92638c8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.26

Release files / mcp_server_k8s-0.1.2-py3-none-any.whl

Download URL mcp_server_k8s-0.1.2-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e43d24d35e09444ccbc987b2eba7f4a3746feb1ba22fa648e2bb647bf78949a2
BLAKE2b-256 checksum
How to use checksums
6bfccb6789f69b0e46d47c3fb1c653beeb384fc950c1fb04071fd8136462cfd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.26

Security for mcp-server-k8s 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page