get_vultr_instance_bandwidth
Retrieve bandwidth usage data for a Vultr cloud instance to monitor network consumption and track resource utilization.
Instructions
获取Vultr实例带宽使用情况
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instance_id | Yes |
Implementation Reference
- main.py:547-552 (handler)MCP tool handler function that registers and executes the tool by delegating to the Vultr provider.@mcp.tool() def get_vultr_instance_bandwidth(instance_id: str) -> Dict: """ 获取Vultr实例带宽使用情况 """ return vultr_provider.get_instance_bandwidth(instance_id)
- providers/vultr_provider.py:335-372 (helper)Core helper method in VultrProvider class that performs the actual API request to Vultr for instance bandwidth data.def get_instance_bandwidth(self, instance_id: str) -> Dict: """ 获取实例的带宽使用情况 Args: instance_id (str): Vultr实例ID Returns: Dict: 带宽信息或错误信息 """ if not self.available: return { 'error': f'Vultr服务不可用: {getattr(self, "error", "未知错误")}', 'provider': 'vultr' } try: response = requests.get(f'{self.base_url}/instances/{instance_id}/bandwidth', headers=self.headers, timeout=10) if response.status_code != 200: return { 'error': f'获取带宽信息失败: {response.status_code} - {response.text}', 'provider': 'vultr' } data = response.json() return { 'provider': 'vultr', 'instance_id': instance_id, 'bandwidth_data': data.get('bandwidth', {}) } except Exception as e: return { 'error': f'获取带宽信息时发生错误: {str(e)}', 'provider': 'vultr' }