Skip to main content
Glama

tos_get_object

Download objects from Volcengine TOS storage by specifying bucket name and object key, with optional base64 encoding for content retrieval.

Instructions

从 TOS 下载对象

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucket_nameYes存储桶名称
object_keyYes对象键名
return_as_base64No是否以base64格式返回内容

Implementation Reference

  • The main handler function that executes the tool logic: retrieves the object from TOS bucket using tos_client.get_object, reads content, encodes as base64 or UTF-8 text based on parameters, and returns structured JSON result.
    async def get_object(args: Dict[str, Any]) -> List[TextContent]: """下载对象""" bucket_name = args["bucket_name"] object_key = args["object_key"] return_as_base64 = args.get("return_as_base64", False) try: resp = tos_client.get_object(bucket_name, object_key) content = resp.read() if return_as_base64: content_str = base64.b64encode(content).decode('utf-8') result = { "content": content_str, "content_type": resp.content_type, "content_length": resp.content_length, "encoding": "base64" } else: try: content_str = content.decode('utf-8') result = { "content": content_str, "content_type": resp.content_type, "content_length": resp.content_length, "encoding": "utf-8" } except UnicodeDecodeError: content_str = base64.b64encode(content).decode('utf-8') result = { "content": content_str, "content_type": resp.content_type, "content_length": resp.content_length, "encoding": "base64" } 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)}")]
  • Input schema definition for the tos_get_object tool, specifying parameters: bucket_name (required), object_key (required), return_as_base64 (optional boolean).
    inputSchema={ "type": "object", "properties": { "bucket_name": { "type": "string", "description": "存储桶名称" }, "object_key": { "type": "string", "description": "对象键名" }, "return_as_base64": { "type": "boolean", "description": "是否以base64格式返回内容", "default": False } }, "required": ["bucket_name", "object_key"] }
  • Tool registration in list_tools(): defines name, description, and input schema for tos_get_object.
    Tool( name="tos_get_object", description="从 TOS 下载对象", inputSchema={ "type": "object", "properties": { "bucket_name": { "type": "string", "description": "存储桶名称" }, "object_key": { "type": "string", "description": "对象键名" }, "return_as_base64": { "type": "boolean", "description": "是否以base64格式返回内容", "default": False } }, "required": ["bucket_name", "object_key"] } ),
  • Dispatch registration in call_tool(): maps tool name 'tos_get_object' to the get_object handler function.
    elif name == "tos_get_object": return await get_object(arguments)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jneless/tos-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server