Skip to main content
Glama
rainhan99

Cloud Manage MCP Server

by rainhan99

power_off_digitalocean_droplet

Shuts down a DigitalOcean droplet after confirming its ID, IP address, and name to prevent accidental power-offs. This tool helps manage cloud server operations through the Cloud Manage MCP Server.

Instructions

强制关闭DigitalOcean Droplet(需要三次确认)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
droplet_idYes
ip_confirmationNo
name_confirmationNo
operation_confirmationNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • main.py:419-430 (registration)
    MCP tool registration and thin handler wrapper that delegates to DigitalOcean provider's power_off_droplet method with security confirmation parameters.
    def power_off_digitalocean_droplet(
        droplet_id: int, 
        ip_confirmation: str = "", 
        name_confirmation: str = "", 
        operation_confirmation: str = ""
    ) -> Dict:
        """
        强制关闭DigitalOcean Droplet(需要三次确认)
        """
        return digitalocean_provider.power_off_droplet(
            droplet_id, ip_confirmation, name_confirmation, operation_confirmation
        )
  • Core handler logic for all DigitalOcean power operations ('power_on', 'power_off', etc.), including triple confirmation validation using SecurityConfirmation, droplet info fetch, and API call to client.droplet_actions.post for executing the power action.
    def _execute_power_operation(
        self, 
        droplet_id: int, 
        operation: str, 
        ip_confirmation: str, 
        name_confirmation: str, 
        operation_confirmation: str
    ) -> Dict:
        """
        执行电源操作的通用函数
        """
        if not self.available:
            return {
                'error': f'DigitalOcean服务不可用: {getattr(self, "error", "未知错误")}',
                'provider': 'digitalocean'
            }
        
        # 首先获取droplet信息
        try:
            droplet_response = self.client.droplets.get(droplet_id)
            droplet = droplet_response.get("droplet", {})
            
            if not droplet:
                return {
                    'error': f'未找到ID为 {droplet_id} 的Droplet',
                    'provider': 'digitalocean'
                }
            
            # 格式化droplet信息用于确认
            droplet_info = self._format_droplet_for_confirmation(droplet)
            
        except Exception as e:
            return {
                'error': f'获取Droplet信息时发生错误: {str(e)}',
                'provider': 'digitalocean'
            }
        
        # 检查是否提供了确认信息
        if not ip_confirmation or not name_confirmation or not operation_confirmation:
            # 返回确认要求
            return require_triple_confirmation(droplet_info, operation)
        
        # 验证确认信息
        security = SecurityConfirmation()
        is_valid, error_message = security.validate_power_operation(
            droplet_info, operation, ip_confirmation, name_confirmation, operation_confirmation
        )
        
        if not is_valid:
            return {
                'error': f'确认验证失败: {error_message}',
                'provider': 'digitalocean',
                'requires_confirmation': True
            }
        
        # 执行实际操作
        try:
            action_data = {"type": operation}
            response = self.client.droplet_actions.post(droplet_id=droplet_id, body=action_data)
            
            action = response.get("action", {})
            
            return {
                'provider': 'digitalocean',
                'droplet_id': droplet_id,
                'operation_success': True,
                'action': {
                    'id': action.get("id"),
                    'status': action.get("status"),
                    'type': action.get("type"),
                    'started_at': action.get("started_at"),
                    'resource_id': action.get("resource_id")
                },
                'message': f'已成功提交 {operation} 操作,操作ID: {action.get("id")}',
                'confirmation_validated': True
            }
            
        except Exception as e:
            return {
                'error': f'执行 {operation} 操作时发生错误: {str(e)}',
                'provider': 'digitalocean'
            }
  • Security helper that validates the triple confirmation (IP, instance name, operation type) required before executing destructive power operations.
    def validate_power_operation(
        instance_info: Dict,
        operation: str,
        ip_confirmation: str,
        name_confirmation: str,
        operation_confirmation: str
    ) -> Tuple[bool, str]:
        """
        验证电源操作的三次确认
        
        Args:
            instance_info (dict): 实例信息
            operation (str): 操作类型 ('shutdown', 'reboot', 'power_off', 'power_on')
            ip_confirmation (str): 用户确认的IP地址
            name_confirmation (str): 用户确认的实例名称
            operation_confirmation (str): 用户确认的操作类型
            
        Returns:
            Tuple[bool, str]: (是否通过验证, 错误信息)
        """
        errors = []
        
        # 获取实例的实际信息
        actual_ip = instance_info.get('public_ip', instance_info.get('public_ipv4', '未知'))
        actual_name = instance_info.get('name', instance_info.get('instance_name', '未知'))
        
        # 第一次确认:IP地址
        if ip_confirmation.strip() != actual_ip:
            errors.append(f"IP地址确认失败: 期望 '{actual_ip}', 但收到 '{ip_confirmation}'")
        
        # 第二次确认:实例名称
        if name_confirmation.strip() != actual_name:
            errors.append(f"实例名称确认失败: 期望 '{actual_name}', 但收到 '{name_confirmation}'")
        
        # 第三次确认:操作类型
        valid_operations = {
            'shutdown': ['shutdown', '关机', '优雅关机'],
            'power_off': ['power_off', '强制关机', '强制断电'],
            'reboot': ['reboot', '重启', '重新启动'],
            'power_on': ['power_on', '开机', '启动']
        }
        
        operation_confirmed = False
        for op, variations in valid_operations.items():
            if op == operation and operation_confirmation.strip().lower() in [v.lower() for v in variations]:
                operation_confirmed = True
                break
        
        if not operation_confirmed:
            expected_ops = valid_operations.get(operation, [operation])
            errors.append(f"操作确认失败: 期望 '{expected_ops[0]}', 但收到 '{operation_confirmation}'")
        
        if errors:
            return False, "; ".join(errors)
        
        return True, "所有确认项目验证通过"
  • Provider-specific entry point for power_off operation that specifies the operation type 'power_off' and delegates to the shared _execute_power_operation helper.
    def power_off_droplet(
        self, 
        droplet_id: int, 
        ip_confirmation: str = "", 
        name_confirmation: str = "", 
        operation_confirmation: str = ""
    ) -> Dict:
        """
        强制关闭Droplet(需要三次确认)
        """
        return self._execute_power_operation(
            droplet_id, 'power_off', ip_confirmation, name_confirmation, operation_confirmation
        )
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It indicates this is a forceful shutdown operation requiring three confirmations, which suggests it's destructive and irreversible. However, it doesn't disclose critical behavioral details like whether this action is immediate, what happens to data, if there are rate limits, or what permissions are required. The description adds some context but leaves significant gaps for a destructive operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise—just one sentence in Chinese that directly states the tool's purpose and a key behavioral requirement. It's front-loaded with the core action and wastes no words, making it efficient for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (a destructive power-off operation), no annotations, 0% schema coverage, and the presence of an output schema (which might help with return values), the description is incomplete. It mentions the need for three confirmations but doesn't cover parameter meanings, error conditions, or other critical context needed for safe and correct usage. The output schema existence doesn't fully compensate for these gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning none of the 4 parameters (droplet_id, ip_confirmation, name_confirmation, operation_confirmation) are documented in the schema. The description doesn't mention any parameters or explain their purposes, such as what the three confirmations entail or how droplet_id should be obtained. This fails to compensate for the lack of schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('强制关闭' means 'force shut down') and the target resource ('DigitalOcean Droplet'), which is specific and unambiguous. It distinguishes this from sibling tools like 'shutdown_digitalocean_droplet' by implying a more forceful action, though it doesn't explicitly name alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions '需要三次确认' (requires three confirmations), which provides some usage context about safety measures. However, it doesn't explicitly state when to use this tool versus alternatives like 'shutdown_digitalocean_droplet' or 'manage_instance_power', nor does it mention prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/rainhan99/cloud_manage_mcp_server'

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