get_digitalocean_droplet_actions
Retrieve the complete action history of a DigitalOcean Droplet by providing its ID, enabling detailed monitoring and management of server operations through the Cloud Manage MCP Server.
Instructions
获取DigitalOcean Droplet操作历史
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| droplet_id | Yes |
Input Schema (JSON Schema)
{
"properties": {
"droplet_id": {
"title": "Droplet Id",
"type": "integer"
}
},
"required": [
"droplet_id"
],
"title": "get_digitalocean_droplet_actionsArguments",
"type": "object"
}
Implementation Reference
- main.py:474-480 (registration)MCP tool registration for get_digitalocean_droplet_actions, which delegates to the provider's method.@mcp.tool() def get_digitalocean_droplet_actions(droplet_id: int) -> Dict: """ 获取DigitalOcean Droplet操作历史 """ return digitalocean_provider.get_droplet_actions(droplet_id)
- Core handler function in DigitalOceanProvider class that fetches and formats the droplet's action history using the DigitalOcean API.def get_droplet_actions(self, droplet_id: int) -> Dict: """ 获取Droplet的操作历史 Args: droplet_id (int): Droplet ID Returns: Dict: 操作历史或错误信息 """ if not self.available: return { 'error': f'DigitalOcean服务不可用: {getattr(self, "error", "未知错误")}', 'provider': 'digitalocean' } try: response = self.client.droplet_actions.list(droplet_id=droplet_id) actions = response.get("actions", []) action_list = [] for action in actions: action_info = { 'id': action.get("id"), 'status': action.get("status"), 'type': action.get("type"), 'started_at': action.get("started_at"), 'completed_at': action.get("completed_at"), 'resource_id': action.get("resource_id"), 'resource_type': action.get("resource_type"), 'region': action.get("region", {}).get("name", "未知") } action_list.append(action_info) return { 'provider': 'digitalocean', 'droplet_id': droplet_id, 'total_actions': len(action_list), 'actions': action_list } except Exception as e: return { 'error': f'获取Droplet操作历史时发生错误: {str(e)}', 'provider': 'digitalocean' }