Skip to main content

Add your description here

Project description

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-postgresql"
    ]
  }
}

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-postgresql

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_server_postgresql-0.1.5.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_server_postgresql-0.1.5-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file mcp_server_postgresql-0.1.5.tar.gz.

File metadata

File hashes

Hashes for mcp_server_postgresql-0.1.5.tar.gz
Algorithm Hash digest
SHA256 cbbe4ba8c77d83793ce1efac709eba38989d1362fba5a16fd6c5f11904d44cae
MD5 e17b55bfdfd065027d3a477ca618a909
BLAKE2b-256 a5b579ec0a41aeec1aef7204173d3a78cf4024cdae84a1501474ae5eb95e63d5

See more details on using hashes here.

File details

Details for the file mcp_server_postgresql-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_server_postgresql-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f0de9d97c802567397f9f14fdd2c2c3a62af1fef4f4376c43b0df1814edb5aaa
MD5 0586b45fd884f9eeef1d5e88f8c9c1e5
BLAKE2b-256 8ae7f1d8a35392017141ba58784c02acb106a78f81b0ef9daea47e5a5b773c22

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page