Skip to main content
Glama
jneless
by jneless

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)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden but only states the basic action. It doesn't disclose behavioral traits like whether this requires authentication, has rate limits, returns binary data or errors for missing objects, or if it's idempotent. For a download operation, this leaves significant gaps in understanding how it behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded and appropriately sized for the tool's purpose, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a download operation (involving data retrieval, potential errors, and no output schema), the description is incomplete. It doesn't explain what is returned (e.g., file content, format, or error handling), and with no annotations, it fails to cover critical behavioral aspects, making it inadequate for safe use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters (bucket_name, object_key, return_as_base64). The description adds no additional meaning beyond implying these are needed for downloading, which is minimal value. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '从 TOS 下载对象' clearly states the action (download) and resource (object from TOS), distinguishing it from siblings like 'tos_put_object' (upload) and 'tos_list_objects' (list). However, it doesn't specify that this downloads the object's content (vs. metadata), which could be inferred but isn't explicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'tos_presigned_url' (for temporary access) or 'tos_get_bucket_meta' (for metadata). The description implies it's for downloading objects, but lacks context on prerequisites (e.g., object must exist) or exclusions (e.g., not for streaming).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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