get_vultr_instance_bandwidth
Retrieve bandwidth usage data for a specific Vultr instance using the instance ID with Cloud Manage MCP Server, enabling efficient resource monitoring and management.
Instructions
获取Vultr实例带宽使用情况
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instance_id | Yes |
Implementation Reference
- main.py:547-553 (handler)The main MCP tool handler function for 'get_vultr_instance_bandwidth', decorated with @mcp.tool() which handles both registration and execution. It receives the instance_id parameter and delegates to the Vultr provider's method.@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 implementation logic in the VultrProvider class method. Makes an authenticated GET request to the Vultr API endpoint for instance bandwidth data, handles errors, and formats the response.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' }
- main.py:547-553 (registration)The @mcp.tool() decorator registers this function as an MCP tool named 'get_vultr_instance_bandwidth', with schema inferred from signature and docstring.@mcp.tool() def get_vultr_instance_bandwidth(instance_id: str) -> Dict: """ 获取Vultr实例带宽使用情况 """ return vultr_provider.get_instance_bandwidth(instance_id)