Metadata-Version: 2.4
Name: k8s-mcp-extension
Version: 0.1.1
Summary: MCP server for Kubernetes command execution, node inspection, and diagnostics
Keywords: kubernetes,mcp,diagnostics,operations
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Systems Administration
Classifier: Typing :: Typed
Requires-Python: >=3.13
Description-Content-Type: text/markdown
Requires-Dist: kubernetes>=32.0.0
Requires-Dist: mcp>=1.22.0
Requires-Dist: pydantic>=2.10.0
Provides-Extra: dev
Requires-Dist: build>=1.2.2; extra == "dev"
Requires-Dist: pytest>=8.3.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.25.0; extra == "dev"
Requires-Dist: pytest-cov>=6.0.0; extra == "dev"
Requires-Dist: ruff>=0.11.0; extra == "dev"
Requires-Dist: twine>=6.1.0; extra == "dev"

# K8s MCP Server

MCP server for Kubernetes command execution, node inspection, and node-level diagnostics. Extension of [k8s-mcp-server](https://github.com/alexei-led/k8s-mcp-server) by alexei-led.

## Features

- validated wrappers around `kubectl`, `helm`, `istioctl`, and `argocd`
- node-aware kubeconfig selection through `K8S_NODE_PREFIX_MAPPING`
- `run_checkup_on_node` for `kubectl node-shell ... checkup -n`
- `get_logs_on_node` for collecting `dmesg`, `journalctl`, `/var/log/*`, and `/var/crash`
- Kubernetes node inspection tools for status, labels, pods, and resources

## Configuration

Set `K8S_NODE_PREFIX_MAPPING` to a JSON object that maps a node prefix to a kubeconfig file name:

```json
{
  "node-a": "cluster-a.config",
  "edge": "edge-cluster.config"
}
```

The kubeconfig files are resolved relative to `K8S_KUBECONFIG_DIR`, which defaults to `~/.kube`.

## Example MCP Client Configuration

When installing from PyPI, you can use the package-matched command name `k8s-mcp-extension`.
The legacy `k8s-mcp-server` command remains available for backward compatibility.

```json
{
  "mcpServers": {
    "k8s-server": {
      "command": "k8s-mcp-extension",
      "cwd": "/absolute/path/to/project",
      "env": {
        "K8S_KUBECONFIG_DIR": "/path/to/.kube",
        "K8S_NODE_PREFIX_MAPPING": "{\"node-a\": \"cluster-a.config\", \"edge\": \"edge-cluster.config\"}",
        "K8S_MCP_TIMEOUT": "600"
      }
    }
  }
}
```

## Development

Create the environment and run checks:

```bash
uv sync --extra dev
.venv/bin/python -m pytest
.venv/bin/python -m ruff check
```

Run the server locally:

```bash
.venv/bin/python -m k8s_mcp_server
```

After installing the package, either console script works:

```bash
k8s-mcp-extension
k8s-mcp-server
```
