Skip to main content
Glama

tos_list_objects

List objects in a TOS bucket with optional filtering by prefix, delimiter, and maximum results to manage storage content effectively.

Instructions

列举 TOS 对象

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucket_nameYes存储桶名称
delimiterNo分隔符
max_keysNo最大返回对象数量
prefixNo对象键前缀

Implementation Reference

  • The main handler function that lists objects in a TOS bucket using tos_client.list_objects_type2, parses the response into a structured JSON format including objects, common prefixes, truncation status, and next token.
    async def list_objects(args: Dict[str, Any]) -> List[TextContent]: """列举对象""" bucket_name = args["bucket_name"] prefix = args.get("prefix", "") delimiter = args.get("delimiter", "") max_keys = args.get("max_keys", 1000) try: resp = tos_client.list_objects_type2(bucket_name, prefix=prefix, delimiter=delimiter, max_keys=max_keys) result = { "objects": [], "common_prefixes": [], "is_truncated": resp.is_truncated, "next_continuation_token": resp.next_continuation_token } for obj in resp.contents: result["objects"].append({ "key": obj.key, "last_modified": str(obj.last_modified) if obj.last_modified else None, "size": obj.size, "etag": obj.etag, "storage_class": str(obj.storage_class) if obj.storage_class else None }) for prefix in resp.common_prefixes: result["common_prefixes"].append(prefix.prefix) 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)}")]
  • Defines the Tool schema for tos_list_objects, including input parameters like bucket_name (required), prefix, delimiter, max_keys with descriptions and defaults.
    Tool( name="tos_list_objects", description="列举 TOS 对象", inputSchema={ "type": "object", "properties": { "bucket_name": { "type": "string", "description": "存储桶名称" }, "prefix": { "type": "string", "description": "对象键前缀", "default": "" }, "delimiter": { "type": "string", "description": "分隔符", "default": "" }, "max_keys": { "type": "integer", "description": "最大返回对象数量", "default": 1000 } }, "required": ["bucket_name"] } ),
  • Registers the tool dispatch in the call_tool handler by mapping the tool name to the list_objects function call.
    elif name == "tos_list_objects": return await list_objects(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