Skip to main content
Glama

start_experiment

Launch AWS Fault Injection Service experiments using predefined templates to test system resilience through controlled chaos engineering scenarios.

Instructions

Start a new AWS FIS experiment based on an experiment template. Args: template_id: ID of the experiment template to use region: AWS region to use (default: us-east-1) client_token: Optional client token for idempotency Returns: JSON string containing the started experiment information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
template_idYes
regionNous-east-1
client_tokenNo

Implementation Reference

  • The core handler function for the 'start_experiment' tool. It uses boto3 to start an AWS FIS experiment from a template ID, handles client tokens for idempotency, serializes the response with datetime handling, and returns JSON. Decorated with @require_write_mode for safety.
    @require_write_mode def start_experiment(template_id: str, region: str = "us-east-1", client_token: Optional[str] = None) -> str: """ Start a new AWS FIS experiment based on an experiment template. Args: template_id: ID of the experiment template to use region: AWS region to use (default: us-east-1) client_token: Optional client token for idempotency Returns: JSON string containing the started experiment information """ try: fis = boto3.client('fis', region_name=region) # Generate a client token if not provided if not client_token: client_token = str(uuid.uuid4()) response = fis.start_experiment( experimentTemplateId=template_id, clientToken=client_token ) # 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 starting experiment: {str(e)}"
  • Registers the start_experiment handler function as an MCP tool using FastMCP's app.tool() decorator.
    app.tool()(start_experiment)
  • Imports the start_experiment function from tools.py, necessary for registration.
    from aws_fis_mcp.tools import ( list_experiment_templates, get_experiment_template, list_experiments, get_experiment, start_experiment, stop_experiment, create_experiment_template, delete_experiment_template, list_action_types, generate_template_example, set_write_mode, )
  • Decorator applied to start_experiment to enforce write mode, preventing accidental destructive operations unless explicitly 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
  • Helper function used in start_experiment to serialize datetime objects in the boto3 response to ISO strings for JSON output.
    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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/RadiumGu/aws-fis-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server