tos_image_info
Retrieve metadata and details about images stored in Volcengine TOS object storage by specifying the bucket name and object key.
Instructions
获取图片信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucket_name | Yes | 存储桶名称 | |
| object_key | Yes | 图片对象键名 |
Implementation Reference
- src/tos_mcp_server/handlers.py:261-293 (handler)The main handler function for the 'tos_image_info' tool. It retrieves image metadata from TOS using the get_object API with process='image/info', parses the JSON response, and returns it structured with bucket and key info.async def image_info(args: Dict[str, Any]) -> List[TextContent]: """获取图片信息""" bucket_name = args["bucket_name"] object_key = args["object_key"] try: # 使用 get_object 方法通过 style 参数获取图片信息 # 设置处理参数为 image/info resp = tos_client.get_object(bucket_name, object_key, process="image/info") image_info_data = resp.read().decode('utf-8') # 尝试解析JSON响应 try: image_info_json = json.loads(image_info_data) result = { "bucket": bucket_name, "key": object_key, "image_info": image_info_json, "status": "success" } except json.JSONDecodeError: # 如果不是JSON格式,直接返回原始数据 result = { "bucket": bucket_name, "key": object_key, "image_info": image_info_data, "status": "success", "note": "返回原始格式数据" } return [TextContent(type="text", text=json.dumps(result, indent=2, ensure_ascii=False))] except Exception as e: return [TextContent(type="text", text=f"获取图片信息失败: {str(e)}")]
- src/tos_mcp_server/server.py:225-242 (registration)Registers the 'tos_image_info' tool in the MCP server's list_tools() function, including name, description, and input schema.Tool( name="tos_image_info", description="获取图片信息", inputSchema={ "type": "object", "properties": { "bucket_name": { "type": "string", "description": "存储桶名称" }, "object_key": { "type": "string", "description": "图片对象键名" } }, "required": ["bucket_name", "object_key"] } ),
- src/tos_mcp_server/server.py:357-358 (registration)In the call_tool dispatcher, routes 'tos_image_info' calls to the image_info handler function.elif name == "tos_image_info": return await image_info(arguments)
- src/tos_mcp_server/server.py:228-241 (schema)Input schema definition for the 'tos_image_info' tool, specifying required parameters bucket_name and object_key.inputSchema={ "type": "object", "properties": { "bucket_name": { "type": "string", "description": "存储桶名称" }, "object_key": { "type": "string", "description": "图片对象键名" } }, "required": ["bucket_name", "object_key"] }