Skip to main content
Glama
qiniu

Qiniu MCP Server

Official
by qiniu

upload_local_file

Upload local files to Qiniu Cloud Storage buckets for cloud storage and management. Specify bucket, file path, and key to transfer files from your local system to Qiniu's cloud infrastructure.

Instructions

Upload a local file to Qiniu bucket.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucketYesQiniu Cloud Storage bucket Name
keyYesThe key under which a file is saved in Qiniu Cloud Storage serves as the unique identifier for the file within that space, typically using the filename.
file_pathYesThe file path of file to upload.
overwriteNoWhether to overwrite the existing object if it already exists.

Implementation Reference

  • MCP tool handler that receives tool call parameters, invokes the storage service's upload_local_file method, and returns the result as TextContent.
    def upload_local_file(self, **kwargs) -> list[types.TextContent]:
        urls = self.storage.upload_local_file(**kwargs)
        return [types.TextContent(type="text", text=str(urls))]
  • Input schema defining parameters for the upload_local_file tool: bucket, key, file_path (required), overwrite (optional).
    inputSchema={
        "type": "object",
        "properties": {
            "bucket": {
                "type": "string",
                "description": _BUCKET_DESC,
            },
            "key": {
                "type": "string",
                "description": "The key under which a file is saved in Qiniu Cloud Storage serves as the unique identifier for the file within that space, typically using the filename.",
            },
            "file_path": {
                "type": "string",
                "description": "The file path of file to upload.",
            },
            "overwrite": {
                "type": "boolean",
                "description": "Whether to overwrite the existing object if it already exists.",
            },
        },
        "required": ["bucket", "key", "file_path"],
    }
  • Registration function that instantiates the tool implementation and registers all storage-related tools, including upload_local_file, using 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,
            ]
        )
  • Core helper function in StorageService that implements the file upload logic using Qiniu SDK: generates upload token with policy, uploads file with qiniu.put_file, handles overwrite, and returns download URLs.
    def upload_local_file(self, bucket: str, key: str, file_path: str, overwrite: bool = False) -> list[dict[str:Any]]:
        policy = {
            "insertOnly": 1,
        }
    
        if overwrite:
            policy["insertOnly"] = 0
            policy["scope"] = f"{bucket}:{key}"
    
        token = self.auth.upload_token(bucket=bucket, key=key, policy=policy)
        ret, info = qiniu.put_file(up_token=token, key=key, file_path=file_path)
        if info.status_code != 200:
            raise Exception(f"Failed to upload object: {info}")
    
        return self.get_object_url(bucket, key)
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'upload' implies a write operation, it doesn't disclose important behavioral traits like authentication requirements, rate limits, file size limitations, network timeout behavior, or what happens on failure. The description is minimal and lacks operational context needed for safe invocation.

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 extremely concise - a single sentence that states the core purpose without any fluff. It's front-loaded with the essential information and contains zero wasted words. This represents optimal conciseness for a basic tool description.

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?

For a file upload tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what happens after upload (success/failure responses, returned identifiers), doesn't mention file format restrictions or size limits, and provides no context about the Qiniu service. The agent would need to guess about important operational aspects.

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?

With 100% schema description coverage, the input schema already documents all 4 parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain parameter relationships, provide examples, or clarify edge cases. The baseline score of 3 reflects adequate but minimal value addition.

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 ('upload') and target resource ('a local file to Qiniu bucket'), making the purpose immediately understandable. It distinguishes from siblings like 'upload_text_data' by specifying 'local file' rather than text data. However, it doesn't explicitly differentiate from all sibling tools beyond this basic distinction.

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 'upload_local_file' over 'upload_text_data' for different content types, or when to use it versus other storage operations. There's no context about prerequisites, limitations, or typical use cases.

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