Skip to main content
Glama
qiniu

Qiniu MCP Server

Official
by qiniu

get_object

Retrieve file contents from Qiniu Cloud Storage by specifying bucket name and object key for data access and management.

Instructions

Get an object contents from Qiniu Cloud bucket. In the GetObject request, specify the full key name for the object.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucketYesQiniu Cloud Storage bucket Name
keyYesKey of the object to get.

Implementation Reference

  • The MCP tool handler for 'get_object', which retrieves the object from the StorageService, processes it based on content type (image or text), and returns appropriate MCP content types (ImageContent or TextContent).
    async def get_object(self, **kwargs) -> list[ImageContent] | list[TextContent]:
        response = await self.storage.get_object(**kwargs)
        file_content = response["Body"]
        content_type = response.get("ContentType", "application/octet-stream")
    
        # 根据内容类型返回不同的响应
        if content_type.startswith("image/"):
            base64_data = base64.b64encode(file_content).decode("utf-8")
            return [
                types.ImageContent(
                    type="image", data=base64_data, mimeType=content_type
                )
            ]
    
        if isinstance(file_content, bytes):
            text_content = file_content.decode("utf-8")
        else:
            text_content = str(file_content)
        return [types.TextContent(type="text", text=text_content)]
  • The input schema and metadata definition for the 'get_object' tool, including name, description, and inputSchema requiring bucket and key.
        types.Tool(
            name="get_object",
            description="Get an object contents from Qiniu Cloud bucket. In the GetObject request, specify the full key name for the object.",
            inputSchema={
                "type": "object",
                "properties": {
                    "bucket": {
                        "type": "string",
                        "description": _BUCKET_DESC,
                    },
                    "key": {
                        "type": "string",
                        "description": "Key of the object to get.",
                    },
                },
                "required": ["bucket", "key"],
            },
        )
    )
  • The register_tools function that instantiates _ToolImpl with StorageService and registers the tool handlers, including get_object, via tools.auto_register_tools.
    def register_tools(storage: StorageService):
        tool_impl = _ToolImpl(storage)
        tools.auto_register_tools(
            [
                tool_impl.list_buckets,
                tool_impl.list_objects,
                tool_impl.get_object,
                tool_impl.upload_text_data,
                tool_impl.upload_local_file,
                tool_impl.get_object_url,
            ]
        )
  • The load function in storage/__init__.py that creates StorageService and calls register_tools to register the tools including 'get_object'.
    def load(cfg: config.Config):
        storage = StorageService(cfg)
        register_tools(storage)
        register_resource_provider(storage)
  • The underlying StorageService.get_object method called by the tool handler, which performs the S3-compatible get_object operation, reads the full body into bytes, and returns the response dict.
    async def get_object(self, bucket: str, key: str) -> Dict[str, Any]:
        if self.config.buckets and bucket not in self.config.buckets:
            logger.warning(f"Bucket {bucket} not in configured bucket list")
            return {}
    
        async with self.s3_session.client(
                "s3",
                aws_access_key_id=self.config.access_key,
                aws_secret_access_key=self.config.secret_key,
                endpoint_url=self.config.endpoint_url,
                region_name=self.config.region_name,
                config=self.s3_config,
        ) as s3:
            # Get the object and its stream
            response = await s3.get_object(Bucket=bucket, Key=key)
            stream = response["Body"]
    
            # Read the entire stream in chunks
            chunks = []
            async for chunk in stream:
                chunks.append(chunk)
    
            # Replace the stream with the complete data
            response["Body"] = b"".join(chunks)
            return response
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool retrieves object contents but doesn't describe what 'contents' means (e.g., raw data, metadata), whether authentication is required, rate limits, error conditions, or the format of the return value. This leaves significant gaps for a tool that performs a read operation.

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

Conciseness4/5

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

The description is concise with two sentences that directly address the tool's function and parameter usage. It avoids unnecessary fluff, though it could be slightly more front-loaded by starting with the core purpose more explicitly.

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 cloud storage retrieval tool with no annotations and no output schema, the description is insufficient. It doesn't explain what 'contents' includes (e.g., file data, metadata), potential authentication needs, error handling, or return format, leaving the agent with incomplete context for proper invocation.

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 input schema has 100% description coverage, with clear documentation for both 'bucket' and 'key' parameters. The description adds minimal value beyond the schema by mentioning 'specify the full key name,' which is already implied by the schema. This meets the baseline for high schema coverage.

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 clearly states the action ('Get an object contents') and resource ('from Qiniu Cloud bucket'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from sibling tools like 'get_object_url' or 'list_objects' that might also retrieve object information, which prevents a perfect score.

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 doesn't mention when to choose 'get_object' over 'get_object_url' (which might return a URL instead of contents) or 'list_objects' (which lists objects rather than retrieving contents), nor does it specify any prerequisites or exclusions for usage.

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/qiniu/qiniu-mcp-server'

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