Command Palette

Search for a command to run...

UnylyUnyly
Browse all

Chaos Mesh Server

FreeNot checked

Enables chaos engineering on Kubernetes clusters by providing tools to inject faults like network delays, pod kills, and HTTP delays, along with cluster inspect

GitHubEmbed

About

Enables chaos engineering on Kubernetes clusters by providing tools to inject faults like network delays, pod kills, and HTTP delays, along with cluster inspection and chaos lifecycle management.

README

Chaos Mesh MCP 服务端,基于 Python FastMCP 实现,提供 Chaos Mesh 混沌实验的 MCP 工具集。

项目结构

chaosmesh-mcp/
├── src/
│   └── chaosmesh_mcp/          # 源代码 (src 布局)
│       ├── __init__.py
│       ├── __main__.py          # python -m 入口
│       ├── server.py            # FastMCP 服务启动
│       ├── tools/               # MCP 工具注册
│       │   ├── chaos.py         # list_chaos / delete_chaos
│       │   ├── cluster.py       # 集群巡检 (namespace/pod/node)
│       │   ├── httpchaos.py     # HTTP 接口级延迟注入
│       │   ├── network_chaos.py # 网络延迟/丢包/外部延迟
│       │   └── pod.py           # Pod Kill 注入
│       ├── services/            # 服务适配层
│       │   ├── kubectl.py       # kubectl 命令封装
│       │   └── chaosmesh.py     # 模板渲染与 Chaos CRD 应用
│       ├── utils/               # 工具函数
│       │   ├── generate.py      # 混沌资源名生成
│       │   ├── response.py      # 统一响应格式
│       │   └── validate.py      # 输入校验
│       └── templates/           # Chaos Mesh YAML 模板
│           ├── network_delay.yaml
│           ├── network_loss.yaml
│           ├── network_external_delay.yaml
│           ├── pod_kill.yaml
│           └── httpchaos_delay.yaml
├── tests/
│   └── __init__.py
├── deploy/k8s/                  # Kubernetes 部署清单
│   ├── deployment.yaml
│   ├── service.yaml
│   ├── ingress.yaml
│   ├── kustomization.yaml
│   ├── kustomizeconfig.yaml
│   ├── .env.config
│   └── .env.secret.example
├── pyproject.toml
├── uv.lock
├── .python-version
├── Dockerfile
└── README.md

运行方式

环境准备

# 确保已安装 uv
uv --version

# 同步依赖(自动创建 .venv 并安装所有依赖)
uv sync

本地运行

# 使用 uv run 启动服务
uv run python -m chaosmesh_mcp

# 或通过 console_scripts
uv run chaosmesh-mcp

Docker

docker build -t chaos-mcp:latest .
docker run -p 8000:8000 chaos-mcp:latest

环境变量

  • MCP_HOST — 服务监听地址,默认 0.0.0.0
  • MCP_PORT — 服务监听端口,默认 8000

功能说明

集群巡检工具 (tools/cluster.py)

  • get_namespaces — 查询集群中的 namespace 列表
  • get_pods — 以 wide 格式列出目标命名空间中的 Pod
  • get_nodes — 以 wide 格式列出集群中的所有节点
  • cluster_info — 获取 Kubernetes 集群端点与服务信息

网络混沌工具 (tools/network_chaos.py)

  • resolve_namespace — 根据 K8s 服务名称查询所在的 namespace
  • network_delay — 对服务与服务之间的网络连接注入延迟
  • network_external_delay — 对发往第三方渠道域名注入响应延迟 (Workflow)
  • network_loss — 对服务间注入 NetworkChaos 丢包故障

HTTP 混沌工具 (tools/httpchaos.py)

  • httpchaos_delay — 按 HTTP 路径和端口精准注入延迟

Pod 混沌工具 (tools/pod.py)

  • pod_kill — PodChaos pod-kill 故障注入

混沌生命周期工具 (tools/chaos.py)

  • list_chaos — 列出指定命名空间中的混沌资源
  • delete_chaos — 按类型、名称和命名空间删除单个混沌资源

响应格式

所有工具返回统一的 JSON 响应:

{
  "success": true,
  "message": "操作描述",
  "data": {
    "kubectl": "kubectl 返回内容",
    "yaml": "渲染后的 YAML"
  },
  "yaml": "渲染后的 YAML (顶层)"
}

Kubernetes 部署

kubectl create namespace chaos-mcp
cp deploy/k8s/.env.secret.example deploy/k8s/.env.secret
# 编辑 deploy/k8s/.env.secret 填入真实值
kubectl apply -k deploy/k8s

from github.com/Ausium/chaosmesh-mcp

Install Chaos Mesh Server in Claude Desktop, Claude Code & Cursor

Recommended · one command, every IDE
unyly install chaos-mesh-mcp-server

Installs into Claude Desktop, Claude Code, Cursor & VS Code — handles npx, uvx and build-from-source repos for you.

First time? Get the CLI: curl -fsSL https://unyly.org/install | sh

Or configure manually

Run in your terminal:

claude mcp add chaos-mesh-mcp-server -- uvx --from git+https://github.com/Ausium/chaosmesh-mcp chaosmesh-mcp

FAQ

Is Chaos Mesh Server MCP free?

Yes, Chaos Mesh Server MCP is free — one-click install via Unyly at no cost.

Does Chaos Mesh Server need an API key?

No, Chaos Mesh Server runs without API keys or environment variables.

Is Chaos Mesh Server hosted or self-hosted?

A hosted option is available: Unyly runs the server in the cloud, no local setup required.

How do I install Chaos Mesh Server in Claude Desktop, Claude Code or Cursor?

Open Chaos Mesh Server on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.

Related MCPs

Compare Chaos Mesh Server with

Not sure what to pick?

Find your stack in 60 seconds

Author?

Embed badge for your README

Browse similar

All development MCPs