Skip to main content
Glama
jneless
by jneless

tos_put_object

Upload objects to TOS storage by providing bucket name, object key, and content, supporting base64 encoding and content type specification.

Instructions

上传对象到 TOS

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucket_nameYes存储桶名称
contentYes文件内容(base64编码)或文本内容
content_typeNo内容类型application/octet-stream
is_base64No内容是否为base64编码
object_keyYes对象键名

Implementation Reference

  • Core handler function that executes the tos_put_object tool: extracts arguments, handles base64 or text content, calls tos_client.put_object to upload, and returns success or error message.
    async def put_object(args: Dict[str, Any]) -> List[TextContent]:
        """上传对象"""
        bucket_name = args["bucket_name"]
        object_key = args["object_key"]
        content = args["content"]
        content_type = args.get("content_type", "application/octet-stream")
        is_base64 = args.get("is_base64", False)
        
        try:
            if is_base64:
                content_bytes = base64.b64decode(content)
            else:
                content_bytes = content.encode('utf-8')
                
            resp = tos_client.put_object(bucket_name, object_key, 
                                       content=content_bytes, 
                                       content_type=content_type,
                                       content_length=len(content_bytes))
            return [TextContent(type="text", text=f"成功上传对象: {object_key} (ETag: {resp.etag})")]
        except Exception as e:
            return [TextContent(type="text", text=f"上传对象失败: {str(e)}")]
  • Input schema definition for the tos_put_object tool, specifying parameters like bucket_name, object_key, content (base64 or text), content_type, and is_base64 flag.
    Tool(
        name="tos_put_object",
        description="上传对象到 TOS",
        inputSchema={
            "type": "object",
            "properties": {
                "bucket_name": {
                    "type": "string",
                    "description": "存储桶名称"
                },
                "object_key": {
                    "type": "string",
                    "description": "对象键名"
                },
                "content": {
                    "type": "string",
                    "description": "文件内容(base64编码)或文本内容"
                },
                "content_type": {
                    "type": "string",
                    "description": "内容类型",
                    "default": "application/octet-stream"
                },
                "is_base64": {
                    "type": "boolean",
                    "description": "内容是否为base64编码",
                    "default": False
                }
            },
            "required": ["bucket_name", "object_key", "content"]
        }
    ),
  • Registers the tool handler dispatch in the call_tool function: routes calls to name 'tos_put_object' to the put_object handler.
    elif name == "tos_put_object":
        return await put_object(arguments)
  • Tool registration in list_tools(): adds tos_put_object to the list of available tools with its schema and description.
    Tool(
        name="tos_put_object",
        description="上传对象到 TOS",
        inputSchema={
            "type": "object",
            "properties": {
                "bucket_name": {
                    "type": "string",
                    "description": "存储桶名称"
                },
                "object_key": {
                    "type": "string",
                    "description": "对象键名"
                },
                "content": {
                    "type": "string",
                    "description": "文件内容(base64编码)或文本内容"
                },
                "content_type": {
                    "type": "string",
                    "description": "内容类型",
                    "default": "application/octet-stream"
                },
                "is_base64": {
                    "type": "boolean",
                    "description": "内容是否为base64编码",
                    "default": False
                }
            },
            "required": ["bucket_name", "object_key", "content"]
        }
    ),
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states '上传对象到 TOS' (upload object to TOS), which implies a write/mutation operation, but does not disclose critical traits such as permissions required, whether it overwrites existing objects, rate limits, error handling, or response format. This is a significant gap for a mutation tool with zero annotation coverage.

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 phrase ('上传对象到 TOS') that is front-loaded and wastes no words. It directly conveys the core action without unnecessary elaboration, making it highly concise and well-structured for its purpose.

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 write operation with 5 parameters and no annotations or output schema, the description is incomplete. It lacks information on behavioral traits (e.g., mutation effects, error cases), output format, and usage context. This is inadequate for a tool that performs object uploads, as it leaves critical operational details unspecified.

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?

The description adds no parameter semantics beyond what the input schema provides. Schema description coverage is 100%, with all parameters well-documented (e.g., bucket_name, content, object_key). The description does not explain parameter interactions, defaults, or usage examples. Baseline 3 is appropriate since the schema does the heavy lifting, but no extra value is added.

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 (upload) and resource (object to TOS) in Chinese, making the purpose understandable. It distinguishes from siblings like tos_delete_object (deletion) and tos_get_object (retrieval). However, it lacks specificity about what 'TOS' refers to (e.g., a storage service), which slightly reduces clarity.

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?

The description provides no guidance on when to use this tool versus alternatives. It does not mention prerequisites (e.g., bucket must exist), exclusions, or comparisons to siblings like tos_presigned_url (for pre-signed uploads) or tos_image_process (for image-specific handling). Usage is implied by the action but not explicitly defined.

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