Chaos Mesh MCP Server

Chaos Mesh MCP Server

Enables AI assistants to perform chaos engineering and resilience testing on Kubernetes clusters through Chaos Mesh. Supports creating and managing 24 types of chaos experiments including network failures, stress tests, pod disruptions, and I/O faults through natural language conversations.

Category
访问服务器

README

Chaos Mesh MCP Server

Model Context Protocol (MCP) server for Chaos Mesh chaos engineering operations.

This MCP server provides AI assistants like Claude with direct access to Chaos Mesh for automated chaos engineering and resilience testing. Create, manage, and validate chaos experiments through natural language conversations.

Features

Chaos Types (24 tools)

  • NetworkChaos (4 tools): Simulate network delays, packet loss, partitions, and corruption
  • StressChaos (3 tools): Apply CPU and memory stress to containers
  • PodChaos (3 tools): Kill pods, fail pods, or kill specific containers
  • IOChaos (4 tools): Inject I/O latency, faults, attribute changes, and data corruption
  • HTTPChaos (4 tools): Abort connections, inject delays, replace/patch HTTP content
  • DNSChaos (2 tools): Return DNS errors or random IPs for specified domains
  • PhysicalMachineChaos (5 tools): Inject chaos on physical/virtual machines (requires Chaosd)

Management & Validation (9 tools)

  • Environment Validation (3 tools): Check prerequisites, verify component status, get chaos-specific requirements
  • Experiment Management (6 tools): Query status, list experiments, delete, pause, resume, get events

Tested Environment

This package has been tested and verified with:

  • Chaos Mesh: v2.8.0
  • Kubernetes: v1.27+ (tested with v1.27.6)
  • kubectl: v1.27.6+
  • Python: 3.10, 3.11, 3.12

Prerequisites

Before using this MCP server, ensure you have:

  1. kubectl installed and configured
  2. Kubernetes cluster accessible via kubectl (v1.15+)
  3. Chaos Mesh installed in the cluster (v2.6+ recommended)

Component-Specific Requirements

  • DNSChaos: Requires chaos-dns-server pod running in chaos-mesh namespace
  • PhysicalMachineChaos: Requires Chaosd agent on target physical/virtual machines
  • Other chaos types: Only require standard Chaos Mesh components (controller-manager, daemon)

Tip: Use the validate_environment tool to check your setup!

Installation

Step 1: Install Chaos Mesh

If Chaos Mesh is not already installed on your cluster:

# Using Helm (Recommended)
helm repo add chaos-mesh https://charts.chaos-mesh.org
helm install chaos-mesh chaos-mesh/chaos-mesh \
  --namespace chaos-mesh \
  --create-namespace \
  --version 2.8.0

# Verify installation
kubectl get pods -n chaos-mesh
# Should see: chaos-controller-manager, chaos-daemon, chaos-dashboard

Step 2: Install MCP Server

Option 1: Install from GitHub (Recommended)

pip install git+https://github.com/ernestolee13/chaos-mesh-mcp.git

Option 2: Install from Source

git clone https://github.com/ernestolee13/chaos-mesh-mcp.git
cd chaos-mesh-mcp
pip install -e .

Quick Start

1. Configure Claude Desktop

Edit ~/.config/claude/claude_desktop_config.json (Linux/Mac) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "chaos-mesh": {
      "command": "python",
      "args": ["-m", "chaos_mesh_mcp.server"]
    }
  }
}

2. Restart Claude Desktop

Restart Claude Desktop to load the MCP server.

3. Validate Your Environment

In Claude Desktop, ask:

You: "Validate my Chaos Mesh environment"
Claude: [Checks kubectl, cluster connection, Chaos Mesh installation, and components]

4. Start Using Chaos Engineering

Example conversations:

You: "Create a network delay of 500ms for pods with label app=api for 2 minutes"
Claude: [Creates NetworkChaos experiment]

You: "Check if DNSChaos is available"
Claude: [Runs check_chaos_type_requirements for dns]

You: "List all active chaos experiments in default namespace"
Claude: [Lists current experiments with their status]

Architecture

chaos-mesh-mcp/
├── chaos_mesh_mcp/
│   ├── server.py           # MCP server main entry point
│   ├── kubectl.py          # Kubectl command runner
│   ├── templates.py        # YAML template rendering
│   ├── validators.py       # Parameter validation
│   └── tools/
│       ├── network.py      # NetworkChaos (4 tools)
│       ├── stress.py       # StressChaos (3 tools)
│       ├── pod.py          # PodChaos (3 tools)
│       ├── io.py           # IOChaos (4 tools)
│       ├── http.py         # HTTPChaos (4 tools)
│       ├── dns.py          # DNSChaos (2 tools)
│       ├── physical.py     # PhysicalMachineChaos (5 tools)
│       ├── validation.py   # Environment validation (3 tools)
│       └── management.py   # Experiment management (6 tools)
├── pyproject.toml          # Package metadata
├── LICENSE                 # MIT License
└── README.md               # This file

Environment Validation

This MCP includes comprehensive environment validation:

validate_environment
├─ Check kubectl availability & version
├─ Check cluster connectivity
├─ Check Chaos Mesh installation
├─ Check CRDs (7 chaos types)
└─ Check components
   ├─ chaos-controller-manager (required)
   ├─ chaos-daemon (required)
   ├─ chaos-dns-server (optional, for DNSChaos)
   └─ chaos-dashboard (optional)

check_chaos_type_requirements(chaos_type)
├─ Verify specific CRD installed
├─ Check required components running
└─ Show external requirements (e.g., Chaosd for Physical)

Troubleshooting

DNSChaos Not Working

# Check if chaos-dns-server is running
kubectl get pods -n chaos-mesh | grep dns

# If not present, install with DNS support:
helm upgrade chaos-mesh chaos-mesh/chaos-mesh --namespace=chaos-mesh --set dnsServer.create=true

PhysicalMachineChaos Not Working

PhysicalMachineChaos requires Chaosd agent on target machines:

Setup Instructions

  1. Install Chaosd on Target Machine (physical or virtual):

    wget https://mirrors.chaos-mesh.org/chaosd-latest-linux-amd64.tar.gz
    tar -xzf chaosd-latest-linux-amd64.tar.gz
    sudo cp chaosd-latest-linux-amd64/chaosd /usr/local/bin/
    sudo apt-get install -y stress-ng  # Required for CPU/Memory stress
    
  2. Start Chaosd Server:

    sudo chaosd server --port 31767
    
  3. Use the Correct Address Format (⚠️ Important):

    # ✓ CORRECT - No protocol prefix
    await create_physical_stress_cpu(
        namespace="default",
        address=["192.168.1.100:31767"],  # IP:PORT only
        duration="60s",
        workers=2,
        load=80
    )
    
    # ✗ WRONG - Including http:// causes HTTPS error
    await create_physical_stress_cpu(
        namespace="default",
        address=["http://192.168.1.100:31767"],  # Don't do this!
        duration="60s"
    )
    

Important Notes

  • Address format: Use IP:PORT or hostname:PORT without http:// or https:// prefix
  • Chaosd can run on localhost: The machine can inject chaos on itself
  • TLS: For production, configure Chaosd with HTTPS (optional for testing)
  • Clock action: Requires pid parameter to target specific process

See: Chaosd Documentation

Permission Errors

Ensure your Kubernetes user has appropriate RBAC permissions:

# Check if you can create chaos experiments
kubectl auth can-i create networkchaos --all-namespaces

Documentation

Based on Chaos Mesh official documentation:

Available Tools (33 total)

NetworkChaos (4 tools)

  • create_network_delay - Inject network latency to simulate slow connections
  • create_network_loss - Simulate packet loss for unreliable networks
  • create_network_partition - Create network splits to test split-brain scenarios
  • create_network_corrupt - Corrupt network packets to test data integrity

StressChaos (3 tools)

  • create_stress_cpu - Apply CPU load to test performance under stress
  • create_stress_memory - Apply memory pressure to test OOM scenarios
  • create_stress_combined - Apply both CPU and memory stress simultaneously

PodChaos (3 tools)

  • create_pod_kill - Kill pods to test recovery mechanisms
  • create_pod_failure - Make pods temporarily unavailable without killing
  • create_container_kill - Kill specific containers within pods

IOChaos (4 tools)

  • create_io_latency - Inject I/O delays to simulate slow disks
  • create_io_fault - Return error codes for file operations (ENOSPC, EIO, etc.)
  • create_io_attr_override - Modify file attributes (permissions, size)
  • create_io_mistake - Inject data corruption into read/write operations

HTTPChaos (4 tools)

  • create_http_abort - Abort HTTP connections to simulate network failures
  • create_http_delay - Inject latency into HTTP requests/responses
  • create_http_replace - Replace HTTP message content (headers, body)
  • create_http_patch - Add content to HTTP messages

DNSChaos (2 tools)

  • create_dns_error - Return DNS errors for specified domain patterns
  • create_dns_random - Return random IP addresses for DNS queries

PhysicalMachineChaos (5 tools)

  • create_physical_stress_cpu - Inject CPU stress on physical/virtual machines
  • create_physical_stress_memory - Inject memory stress on physical/virtual machines
  • create_physical_disk_fill - Fill disk space on physical/virtual machines
  • create_physical_process_kill - Kill processes on physical/virtual machines
  • create_physical_clock_skew - Skew system clock on physical/virtual machines

Environment Validation (3 tools)

  • validate_environment - Comprehensive environment validation (kubectl, cluster, Chaos Mesh, CRDs, components)
  • check_chaos_type_requirements - Check requirements for specific chaos type
  • get_chaos_requirements - Get detailed requirements for a chaos type

Experiment Management (6 tools)

  • get_experiment_status - Get detailed status of a chaos experiment
  • list_active_experiments - List all active experiments in cluster
  • delete_experiment - Delete a chaos experiment
  • pause_experiment - Pause a running experiment
  • resume_experiment - Resume a paused experiment
  • get_experiment_events - Get Kubernetes events for debugging

License

MIT License - see LICENSE file for details.

Contributing

This is part of the chaos-agents project. Issues and pull requests are welcome!

Credits

Built on top of:

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选