list_vultr_instances
Retrieve a list of all Vultr cloud server instances to view current deployments and manage resources.
Instructions
列出所有Vultr实例
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_vultr_instances"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- main.py:540-546 (handler)The MCP tool handler function decorated with @mcp.tool(), which registers and implements the list_vultr_instances tool by delegating to vultr_provider.list_instances().
@mcp.tool() def list_vultr_instances() -> Dict: """ 列出所有Vultr实例 """ return vultr_provider.list_instances() - providers/vultr_provider.py:139-184 (helper)The supporting method in VultrProvider class that implements the core logic of listing all Vultr instances using the Vultr API v2 /instances endpoint, formatting the response.
def list_instances(self) -> Dict: """ 列出所有Vultr实例 Returns: Dict: 实例列表或错误信息 """ if not self.available: return { 'error': f'Vultr服务不可用: {getattr(self, "error", "未知错误")}', 'provider': 'vultr' } try: response = requests.get(f'{self.base_url}/instances', headers=self.headers, timeout=10) if response.status_code != 200: return { 'error': f'Vultr API调用失败: {response.status_code} - {response.text}', 'provider': 'vultr' } data = response.json() instances = data.get('instances', []) instance_list = [] for instance in instances: instance_info = self._format_instance_summary(instance) instance_list.append(instance_info) return { 'provider': 'vultr', 'total_instances': len(instance_list), 'instances': instance_list } except requests.RequestException as e: return { 'error': f'网络请求失败: {str(e)}', 'provider': 'vultr' } except Exception as e: return { 'error': f'列出Vultr实例时发生错误: {str(e)}', 'provider': 'vultr' } - providers/vultr_provider.py:433-433 (helper)Global instantiation of the VultrProvider class instance used by the tool handler.
vultr_provider = VultrProvider() - main.py:540-540 (registration)The @mcp.tool() decorator that registers the list_vultr_instances function as an MCP tool.
@mcp.tool()