Skip to main content
Glama
rainhan99

Cloud Manage MCP Server

by rainhan99

manage_instance_power

Control cloud instance power states across multiple providers, enabling power on, power off, reboot, and shutdown operations with confirmation steps.

Instructions

通用的实例电源管理函数(支持所有云平台)

Args:
    provider (str): 云服务提供商 ('digitalocean', 'vultr', 'alibaba')
    instance_id (str): 实例ID
    action (str): 操作类型 ('power_on', 'power_off', 'reboot', 'shutdown')
    ip_confirmation (str): 确认IP地址
    name_confirmation (str): 确认实例名称
    operation_confirmation (str): 确认操作类型
    
Returns:
    Dict: 操作结果

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
providerYes
instance_idYes
actionYes
ip_confirmationNo
name_confirmationNo
operation_confirmationNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • main.py:220-323 (handler)
    Primary handler and registration for the 'manage_instance_power' MCP tool. Validates provider and action, dispatches to provider-specific power management functions in DigitalOcean, Vultr, and Alibaba providers with triple confirmation security checks.
    @mcp.tool()
    def manage_instance_power(
        provider: str, 
        instance_id: str, 
        action: str,
        ip_confirmation: str = "", 
        name_confirmation: str = "", 
        operation_confirmation: str = ""
    ) -> Dict:
        """
        通用的实例电源管理函数(支持所有云平台)
        
        Args:
            provider (str): 云服务提供商 ('digitalocean', 'vultr', 'alibaba')
            instance_id (str): 实例ID
            action (str): 操作类型 ('power_on', 'power_off', 'reboot', 'shutdown')
            ip_confirmation (str): 确认IP地址
            name_confirmation (str): 确认实例名称
            operation_confirmation (str): 确认操作类型
            
        Returns:
            Dict: 操作结果
        """
        provider_name = provider.lower()
        
        # AWS不支持电源管理
        if provider_name == 'aws':
            return {
                'error': 'AWS平台仅支持只读查询,不允许执行电源管理操作',
                'provider': 'aws',
                'suggestion': '如需管理AWS实例,请使用AWS控制台或CLI'
            }
        
        if provider_name not in ['digitalocean', 'vultr', 'alibaba']:
            return {
                'error': f'不支持的云服务提供商: {provider_name}',
                'supported_providers': ['digitalocean', 'vultr', 'alibaba']
            }
        
        if action not in ['power_on', 'power_off', 'reboot', 'shutdown']:
            return {
                'error': f'不支持的操作类型: {action}',
                'supported_actions': ['power_on', 'power_off', 'reboot', 'shutdown']
            }
        
        provider_obj = PROVIDERS[provider_name]
        provider_info = get_cloud_provider_info(provider_name)
        
        # 检查提供商是否可用
        if not getattr(provider_obj, 'available', False):
            error_msg = getattr(provider_obj, 'error', '提供商不可用')
            return {
                'error': f'{provider_info["name"]} 提供商不可用: {error_msg}',
                'provider': provider_name
            }
        
        print(f"🎯 {provider_info['name']} 电源管理: {action} for {instance_id}")
        
        try:
            # 调用对应提供商的电源管理方法
            if provider_name == 'digitalocean':
                droplet_id = int(instance_id) if instance_id.isdigit() else None
                if not droplet_id:
                    return {'error': 'DigitalOcean Droplet ID必须是数字'}
                    
                if action == 'power_on':
                    return provider_obj.power_on_droplet(droplet_id, ip_confirmation, name_confirmation, operation_confirmation)
                elif action == 'power_off':
                    return provider_obj.power_off_droplet(droplet_id, ip_confirmation, name_confirmation, operation_confirmation)
                elif action == 'reboot':
                    return provider_obj.reboot_droplet(droplet_id, ip_confirmation, name_confirmation, operation_confirmation)
                elif action == 'shutdown':
                    return provider_obj.shutdown_droplet(droplet_id, ip_confirmation, name_confirmation, operation_confirmation)
                    
            elif provider_name == 'vultr':
                if action == 'power_on':
                    return provider_obj.power_on_instance(instance_id, ip_confirmation, name_confirmation, operation_confirmation)
                elif action == 'power_off':
                    return provider_obj.power_off_instance(instance_id, ip_confirmation, name_confirmation, operation_confirmation)
                elif action == 'reboot':
                    return provider_obj.reboot_instance(instance_id, ip_confirmation, name_confirmation, operation_confirmation)
                elif action == 'shutdown':
                    # Vultr可能不支持优雅关闭,使用强制关闭
                    return provider_obj.power_off_instance(instance_id, ip_confirmation, name_confirmation, operation_confirmation)
                    
            elif provider_name == 'alibaba':
                if action == 'power_on':
                    return provider_obj.power_on_instance(instance_id, ip_confirmation, name_confirmation, operation_confirmation)
                elif action == 'power_off':
                    return provider_obj.power_off_instance(instance_id, ip_confirmation, name_confirmation, operation_confirmation)
                elif action == 'reboot':
                    return provider_obj.reboot_instance(instance_id, ip_confirmation, name_confirmation, operation_confirmation)
                elif action == 'shutdown':
                    # 阿里云使用power_off作为关闭操作
                    return provider_obj.power_off_instance(instance_id, ip_confirmation, name_confirmation, operation_confirmation)
            
        except Exception as e:
            return {
                'error': f'执行 {action} 操作时发生错误: {str(e)}',
                'provider': provider_name,
                'instance_id': instance_id,
                'action': action
            }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the tool supports multiple cloud platforms and lists parameters, but doesn't describe critical behavioral aspects: whether this is a destructive operation (power off/reboot/shutdown clearly are), what permissions are required, whether operations are reversible, error handling, rate limits, or what the return dictionary contains. For a power management tool with potentially destructive actions, this is a significant gap.

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

Conciseness4/5

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

The description is efficiently structured with a clear purpose statement followed by Args and Returns sections. Every sentence serves a purpose: establishing scope, documenting parameters, and indicating return type. The parameter documentation is comprehensive yet concise. Minor improvement could be adding a brief usage note about the confirmation parameters.

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

Completeness3/5

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

Given this is a potentially destructive power management tool with 6 parameters, no annotations, and an output schema (though unspecified), the description is moderately complete. It covers parameters well and states the return type, but lacks critical behavioral context about destructive operations, permissions, and error handling. The presence of an output schema means the description doesn't need to detail return values, but other gaps remain significant for safe tool invocation.

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

Parameters4/5

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

With 0% schema description coverage, the description provides substantial parameter information beyond the bare schema. It documents all 6 parameters with their purposes: provider (with specific platform options), instance_id, action (with specific operation types), and three confirmation parameters. This compensates well for the schema's lack of descriptions, though it doesn't explain the confirmation parameters' exact validation logic or format requirements.

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 tool's purpose as '通用的实例电源管理函数(支持所有云平台)' which translates to 'general instance power management function (supports all cloud platforms)'. This specifies the verb (manage power) and resource (instances), and mentions multi-platform support. However, it doesn't explicitly distinguish this unified tool from the many provider-specific power management siblings like 'power_on_alibaba_instance' or 'reboot_digitalocean_droplet'.

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 provides no guidance on when to use this tool versus the many provider-specific alternatives listed among siblings. There's no mention of prerequisites, trade-offs between using this unified tool versus individual provider tools, or any context about when this multi-platform approach is preferable. The agent must infer usage from the description's mention of supporting all platforms.

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