Skip to main content
Glama
RadiumGu
by RadiumGu

create_experiment_template

Create AWS FIS experiment templates to define chaos engineering scenarios with targets, actions, and stop conditions for testing system resilience.

Instructions

Create a new AWS FIS experiment template.

Args:
    name: Name for the experiment template
    description: Description of the experiment template
    targets: Dictionary of targets configuration
    actions: Dictionary of actions configuration
    role_arn: ARN of the IAM role to use for the experiment
    stop_conditions: List of stop conditions
    region: AWS region to use (default: us-east-1)
    
Returns:
    JSON string containing the created template information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
descriptionYes
targetsYes
actionsYes
role_arnYes
stop_conditionsYes
regionNous-east-1

Implementation Reference

  • The handler function for the 'create_experiment_template' tool. It is decorated with @require_write_mode and uses boto3 to create an AWS FIS experiment template, returning formatted JSON.
    @require_write_mode
    def create_experiment_template(
        name: str,
        description: str,
        targets: Dict[str, Dict[str, Any]],
        actions: Dict[str, Dict[str, Any]],
        role_arn: str,
        stop_conditions: List[Dict[str, Any]],
        region: str = "us-east-1"
    ) -> str:
        """
        Create a new AWS FIS experiment template.
        
        Args:
            name: Name for the experiment template
            description: Description of the experiment template
            targets: Dictionary of targets configuration
            actions: Dictionary of actions configuration
            role_arn: ARN of the IAM role to use for the experiment
            stop_conditions: List of stop conditions
            region: AWS region to use (default: us-east-1)
            
        Returns:
            JSON string containing the created template information
        """
        try:
            fis = boto3.client('fis', region_name=region)
            
            response = fis.create_experiment_template(
                clientToken=str(uuid.uuid4()),
                description=description,
                targets=targets,
                actions=actions,
                stopConditions=stop_conditions,
                roleArn=role_arn,
                tags={'Name': name}
            )
            
            # Format the response for better readability
            template = response.get('experimentTemplate', {})
            formatted_template = {
                'id': template.get('id'),
                'description': template.get('description'),
                'creationTime': template.get('creationTime').isoformat() if template.get('creationTime') else None,
                'tags': template.get('tags', {})
            }
            
            return json.dumps(formatted_template, indent=2)
        except Exception as e:
            return f"Error creating experiment template: {str(e)}"
  • Registers the create_experiment_template handler as a tool in the FastMCP server instance.
    app.tool()(create_experiment_template)
  • Decorator applied to the handler that enforces write mode requirement, preventing execution unless --allow-writes is 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
  • Global function to set the write mode flag used by the require_write_mode decorator.
    def set_write_mode(enabled: bool) -> None:
        """Set the global write mode."""
        global _WRITE_MODE_ENABLED
        _WRITE_MODE_ENABLED = enabled
  • Import of the create_experiment_template handler from tools module for use in server registration.
    create_experiment_template,

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