Skip to main content
Glama
rainhan99

Cloud Manage MCP Server

by rainhan99

get_instance_by_provider

Retrieve cloud instance details by specifying the provider and instance identifier. Use this tool to query instance information from AWS, DigitalOcean, Vultr, or Alibaba Cloud.

Instructions

通过明确指定的云服务提供商查询实例信息

Args:
    provider (str): 云服务提供商 ('aws', 'digitalocean', 'vultr', 'alibaba')
    identifier (str): 实例标识符(IP地址或实例ID)
    
Returns:
    Dict: 实例信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
providerYes
identifierYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • main.py:149-218 (handler)
    The handler function implementing the 'get_instance_by_provider' MCP tool. It is registered via @mcp.tool() decorator. Dispatches to provider-specific methods based on provider name and identifier type (IP or ID).
    def get_instance_by_provider(provider: str, identifier: str) -> Dict:
        """
        通过明确指定的云服务提供商查询实例信息
        
        Args:
            provider (str): 云服务提供商 ('aws', 'digitalocean', 'vultr', 'alibaba')
            identifier (str): 实例标识符(IP地址或实例ID)
            
        Returns:
            Dict: 实例信息
        """
        provider_name = provider.lower()
        
        if provider_name not in PROVIDERS:
            return {
                'error': f'不支持的云服务提供商: {provider_name}',
                'supported_providers': list(PROVIDERS.keys())
            }
        
        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,
                'suggestion': '请检查相关环境变量是否正确配置'
            }
        
        print(f"🎯 直接查询 {provider_info['name']} 实例: {identifier}")
        
        try:
            # 根据标识符类型判断查询方式
            if provider_name == 'aws':
                if identifier.startswith('i-'):
                    result = provider_obj.get_instance_by_id(identifier)
                else:
                    result = provider_obj.get_instance_by_ip(identifier)
            elif provider_name == 'digitalocean':
                if identifier.isdigit():
                    result = provider_obj.get_droplet_by_id(int(identifier))
                else:
                    result = provider_obj.get_droplet_by_ip(identifier)
            elif provider_name == 'vultr':
                # Vultr实例ID通常是UUID格式
                if len(identifier) > 16 and '-' in identifier:
                    result = provider_obj.get_instance_by_id(identifier)
                else:
                    result = provider_obj.get_instance_by_ip(identifier)
            elif provider_name == 'alibaba':
                if identifier.startswith('i-'):
                    result = provider_obj.get_instance_by_id(identifier)
                else:
                    result = provider_obj.get_instance_by_ip(identifier)
            
            # 添加提供商信息
            result['provider'] = provider_name
            result['provider_info'] = provider_info
            result['search_identifier'] = identifier
            
            return result
            
        except Exception as e:
            return {
                'error': f'查询 {provider_info["name"]} 实例时发生错误: {str(e)}',
                'provider': provider_name,
                'identifier': identifier
            }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states this is a query operation ('查询'), implying read-only behavior, but doesn't disclose authentication requirements, rate limits, error conditions, or what happens if the instance doesn't exist. For a tool with no annotation coverage, this leaves significant behavioral gaps.

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 efficiently structured with a clear purpose statement followed by Args and Returns sections. Every sentence earns its place: the first sentence states the purpose, and the parameter/return explanations are necessary given the 0% schema coverage. No wasted words.

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

Completeness4/5

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

Given 2 parameters with 0% schema coverage and no annotations, the description does well by fully explaining parameter semantics. The presence of an output schema (Returns: Dict) means the description doesn't need to detail return values. However, for a read operation with no annotations, it could better address authentication, errors, or rate limits.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate fully. It provides clear parameter semantics: 'provider' is explained as cloud service provider with enumerated values ('aws', 'digitalocean', 'vultr', 'alibaba'), and 'identifier' is explained as instance identifier (IP address or instance ID). This adds essential meaning beyond the bare schema.

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 '查询实例信息' (query instance information) with a specific resource (instances) and verb (query). It distinguishes itself from siblings by specifying '通过明确指定的云服务提供商' (through explicitly specified cloud service provider), which differentiates it from generic instance query tools like 'get_instance_info'. However, it doesn't fully distinguish from provider-specific tools like 'get_aws_instance_info' beyond being multi-provider.

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

Usage Guidelines3/5

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

The description implies usage context through the parameter descriptions (provider and identifier), suggesting this tool is for querying instances when you know both the provider and identifier. However, it doesn't explicitly state when to use this versus the many sibling tools (like provider-specific instance info tools or list tools), 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