stop_experiment
Stop a running AWS Fault Injection Service experiment by providing its ID to halt chaos engineering tests and prevent further system disruptions.
Instructions
Stop a running AWS FIS experiment.
Args:
experiment_id: ID of the experiment to stop
region: AWS region to use (default: us-east-1)
Returns:
JSON string containing the stopped experiment information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| experiment_id | Yes | ||
| region | No | us-east-1 |
Implementation Reference
- aws_fis_mcp/tools.py:214-237 (handler)The core handler function for the 'stop_experiment' tool. It uses boto3 to stop an AWS FIS experiment by ID in a given region, serializes the response handling datetimes, and returns formatted JSON or error message.@require_write_mode def stop_experiment(experiment_id: str, region: str = "us-east-1") -> str: """ Stop a running AWS FIS experiment. Args: experiment_id: ID of the experiment to stop region: AWS region to use (default: us-east-1) Returns: JSON string containing the stopped experiment information """ try: fis = boto3.client('fis', region_name=region) response = fis.stop_experiment(id=experiment_id) # Get the raw experiment data and serialize datetime objects experiment = response.get('experiment', {}) serialized_experiment = _serialize_datetime(experiment) return json.dumps(serialized_experiment, indent=2) except Exception as e: return f"Error stopping experiment: {str(e)}"
- aws_fis_mcp/server.py:30-30 (registration)Registration of the stop_experiment function as a tool in the FastMCP application.app.tool()(stop_experiment)
- aws_fis_mcp/tools.py:34-52 (helper)Helper function used by stop_experiment to recursively serialize datetime objects in the AWS response to ISO strings for safe JSON dumping.def _serialize_datetime(obj: Any) -> Any: """ Recursively serialize datetime objects to ISO format strings. Args: obj: Object that may contain datetime objects Returns: Object with datetime objects converted to ISO format strings """ if isinstance(obj, datetime): return obj.isoformat() elif isinstance(obj, dict): return {key: _serialize_datetime(value) for key, value in obj.items()} elif isinstance(obj, list): return [_serialize_datetime(item) for item in obj] else: return obj
- aws_fis_mcp/tools.py:19-32 (helper)Decorator applied to stop_experiment to enforce write mode requirement, preventing execution unless enabled.def require_write_mode(func): """Decorator to require write mode for destructive operations.""" @wraps(func) def wrapper(*args, **kwargs): if not _WRITE_MODE_ENABLED: return json.dumps({ "error": "Write operations are disabled", "message": f"The '{func.__name__}' operation requires write mode. Please restart the server with --allow-writes flag to enable write operations.", "operation": func.__name__, "read_only_mode": True }, indent=2) return func(*args, **kwargs) return wrapper