Skip to main content
Glama
rainhan99

Cloud Manage MCP Server

by rainhan99

list_digitalocean_droplets

Retrieve a list of all DigitalOcean droplets to monitor status, manage resources, and perform operations on cloud servers.

Instructions

列出所有DigitalOcean Droplets

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • main.py:460-460 (registration)
    Registration of the list_digitalocean_droplets tool using @mcp.tool() decorator
    @mcp.tool()
  • main.py:460-466 (handler)
    Handler function for the MCP tool 'list_digitalocean_droplets', which delegates to the DigitalOcean provider's list_droplets method.
    @mcp.tool()
    def list_digitalocean_droplets() -> Dict:
        """
        列出所有DigitalOcean Droplets
        """
        return digitalocean_provider.list_droplets()
  • Core helper method in DigitalOceanProvider class that lists all droplets using the pydo Client API, formats them, and handles errors.
    def list_droplets(self) -> Dict:
        """
        列出所有Droplets
        
        Returns:
            Dict: Droplets列表或错误信息
        """
        if not self.available:
            return {
                'error': f'DigitalOcean服务不可用: {getattr(self, "error", "未知错误")}',
                'provider': 'digitalocean'
            }
        
        try:
            response = self.client.droplets.list()
            droplets = response.get("droplets", [])
            
            droplet_list = []
            for droplet in droplets:
                droplet_info = self._format_droplet_summary(droplet)
                droplet_list.append(droplet_info)
            
            return {
                'provider': 'digitalocean',
                'total_droplets': len(droplet_list),
                'droplets': droplet_list
            }
            
        except Exception as e:
            return {
                'error': f'获取Droplets列表时发生错误: {str(e)}',
                'provider': 'digitalocean'
            }
  • Supporting helper function that formats individual droplet data into a summary for the list output.
    def _format_droplet_summary(self, droplet: Dict) -> Dict:
        """格式化Droplet摘要信息"""
        networks = droplet.get("networks", {})
        public_ip = None
        private_ip = None
        
        for net in networks.get("v4", []):
            if net.get("type") == "public":
                public_ip = net.get("ip_address")
            elif net.get("type") == "private":
                private_ip = net.get("ip_address")
        
        return {
            'id': droplet.get("id"),
            'name': droplet.get("name"),
            'status': droplet.get("status"),
            'size_slug': droplet.get("size_slug"),
            'memory': droplet.get("memory"),
            'vcpus': droplet.get("vcpus"),
            'disk': droplet.get("disk"),
            'region': droplet.get("region", {}).get("name"),
            'public_ipv4': public_ip,
            'private_ipv4': private_ip,
            'created_at': droplet.get("created_at"),
            'tags': droplet.get("tags", [])
        }

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