Skip to main content
Glama
qiniu

Qiniu MCP Server

Official
by qiniu

upload_text_data

Transfer text data to Qiniu Cloud Storage by specifying a bucket, key, and optional overwrite setting. Ideal for managing and storing textual content in Qiniu's cloud infrastructure.

Instructions

Upload text data to Qiniu bucket.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucketYesQiniu Cloud Storage bucket Name
dataYesThe data to upload.
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.
overwriteNoWhether to overwrite the existing object if it already exists.

Implementation Reference

  • MCP tool handler for 'upload_text_data', decorated with tool metadata including input schema. Delegates to StorageService.upload_text_data and returns formatted TextContent response.
    @tools.tool_meta( types.Tool( name="upload_text_data", description="Upload text data to Qiniu bucket.", 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.", }, "data": { "type": "string", "description": "The data to upload.", }, "overwrite": { "type": "boolean", "description": "Whether to overwrite the existing object if it already exists.", }, }, "required": ["bucket", "key", "data"], } ) ) def upload_text_data(self, **kwargs) -> list[types.TextContent]: urls = self.storage.upload_text_data(**kwargs) return [types.TextContent(type="text", text=str(urls))]
  • Registration of the upload_text_data tool handler instance in the tools.auto_register_tools call.
    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 method in StorageService that performs the actual upload_text_data using Qiniu SDK, generates upload token with policy, uploads data, and returns object URLs.
    def upload_text_data(self, bucket: str, key: str, data: 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_data(up_token=token, key=key, data=bytes(data, encoding="utf-8")) if info.status_code != 200: raise Exception(f"Failed to upload object: {info}") return self.get_object_url(bucket, key)

Other Tools

Related 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