Skip to main content
Glama
rainhan99

Cloud Manage MCP Server

by rainhan99

get_instance_info

Detect cloud service providers from IP addresses and retrieve detailed instance information for AWS, DigitalOcean, Vultr, or Alibaba Cloud.

Instructions

根据IP地址自动检测云服务提供商并获取实例信息

Args:
    ip_address (str): 公网IP地址
    provider (str, optional): 明确指定的云服务提供商 ('aws', 'digitalocean', 'vultr', 'alibaba')
    
Returns:
    Dict: 实例信息,包含提供商信息和实例详情

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ip_addressYes
providerNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • main.py:50-147 (handler)
    The core handler function for the 'get_instance_info' MCP tool. It is registered via the @mcp.tool() decorator. The function detects the cloud provider (AWS, DigitalOcean, Vultr, Alibaba) from the IP address using IPINFO or uses the specified provider, checks availability, and calls the provider-specific method to fetch instance information.
    @mcp.tool()
    def get_instance_info(ip_address: str, provider: Optional[str] = None) -> Dict:
        """
        根据IP地址自动检测云服务提供商并获取实例信息
        
        Args:
            ip_address (str): 公网IP地址
            provider (str, optional): 明确指定的云服务提供商 ('aws', 'digitalocean', 'vultr', 'alibaba')
            
        Returns:
            Dict: 实例信息,包含提供商信息和实例详情
        """
        # 如果用户明确指定了云服务提供商,直接使用
        if provider:
            provider_name = provider.lower()
            if provider_name not in PROVIDERS:
                return {
                    'error': f'不支持的云服务提供商: {provider_name}',
                    'supported_providers': list(PROVIDERS.keys()),
                    'suggestion': f'请使用以下支持的提供商之一: {", ".join(PROVIDERS.keys())}'
                }
            
            # 直接使用指定的提供商,跳过IP检测
            provider_obj = PROVIDERS[provider_name]
            provider_info = get_cloud_provider_info(provider_name)
            
            print(f"🎯 用户指定云服务提供商: {provider_info['name']}")
            
        else:
            # 检测云服务提供商
            print("🔍 正在检测IP地址对应的云服务提供商...")
            provider_name = detect_cloud_provider(ip_address, IPINFO_API_TOKEN)
            provider_info = get_cloud_provider_info(provider_name)
            
            if provider_name == 'unknown':
                return {
                    'error': '无法识别IP地址对应的云服务提供商',
                    'ip_address': ip_address,
                    'detected_provider': 'unknown',
                    'suggestion': '请手动指定云服务提供商或检查IP地址是否正确',
                    'supported_providers': list(PROVIDERS.keys()),
                    'manual_usage': '您可以在调用时添加 provider 参数来明确指定云厂商,例如:get_instance_info(ip_address="1.2.3.4", provider="aws")'
                }
            
            # 获取对应的提供商
            provider_obj = PROVIDERS.get(provider_name)
            if not provider_obj:
                return {
                    'error': f'不支持的云服务提供商: {provider_name}',
                    'detected_provider': provider_name,
                    'supported_providers': list(PROVIDERS.keys())
                }
            
            print(f"✅ 检测到云服务提供商: {provider_info['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,
                'provider_info': provider_info,
                'suggestion': '请检查相关环境变量是否正确配置'
            }
        
        # 调用提供商的查询方法
        print(f"🔍 正在查询 {provider_info['name']} 实例信息...")
        
        try:
            if provider_name == 'aws':
                result = provider_obj.get_instance_by_ip(ip_address)
            elif provider_name == 'digitalocean':
                result = provider_obj.get_droplet_by_ip(ip_address)
            elif provider_name == 'vultr':
                result = provider_obj.get_instance_by_ip(ip_address)
            elif provider_name == 'alibaba':
                result = provider_obj.get_instance_by_ip(ip_address)
            else:
                return {
                    'error': f'提供商 {provider_name} 的查询方法未实现',
                    'detected_provider': provider_name
                }
            
            # 添加检测信息到结果中
            result['detected_provider'] = provider_name if not provider else f'{provider_name} (用户指定)'
            result['provider_info'] = provider_info
            result['search_ip'] = ip_address
            
            return result
            
        except Exception as e:
            return {
                'error': f'查询 {provider_info["name"]} 实例时发生错误: {str(e)}',
                'provider': provider_name,
                'provider_info': provider_info,
                'search_ip': ip_address
            }
  • main.py:51-61 (schema)
    Input schema defined by function parameters and docstring: ip_address (required str), provider (optional str). Returns Dict with instance info or error.
    def get_instance_info(ip_address: str, provider: Optional[str] = None) -> Dict:
        """
        根据IP地址自动检测云服务提供商并获取实例信息
        
        Args:
            ip_address (str): 公网IP地址
            provider (str, optional): 明确指定的云服务提供商 ('aws', 'digitalocean', 'vultr', 'alibaba')
            
        Returns:
            Dict: 实例信息,包含提供商信息和实例详情
        """
  • main.py:50-50 (registration)
    The @mcp.tool() decorator registers the get_instance_info function as an MCP tool.
    @mcp.tool()
Behavior3/5

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

With no annotations provided, the description carries full burden. It describes the core behavior (automatic detection + instance retrieval) and mentions the return format (Dict with provider info and instance details). However, it doesn't disclose important behavioral aspects like error handling, rate limits, authentication requirements, or whether this is a read-only 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 perfectly structured and concise. It begins with a clear purpose statement, then provides well-organized Args and Returns sections. Every sentence earns its place, with no redundant information. The bilingual format (Chinese purpose, English parameter names) is efficient.

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 the tool has an output schema (Returns: Dict), the description doesn't need to detail return values. It adequately covers the tool's purpose and parameters. However, for a tool with no annotations and moderate complexity (automatic detection logic), additional behavioral context about error cases or limitations would improve completeness.

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?

The description adds significant value beyond the schema. With 0% schema description coverage, the description fully documents both parameters: ip_address is explained as a public IP address, and provider is clearly described as optional with specific allowed values ('aws', 'digitalocean', 'vultr', 'alibaba'). This completely compensates for the schema's lack of descriptions.

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

Purpose5/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: '根据IP地址自动检测云服务提供商并获取实例信息' (Automatically detect cloud service provider based on IP address and get instance information). It specifies both the detection and retrieval functions, distinguishing it from sibling tools like get_aws_instance_info which require explicit provider specification.

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

Usage Guidelines4/5

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

The description provides clear context for usage: it automatically detects the provider when only an IP is given, but allows optional explicit provider specification. However, it doesn't explicitly state when NOT to use it or name specific alternatives among the many sibling tools.

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