Skip to main content
Glama

CreateUploadUrl

获取文件上传地址,适用于图片、视频等各类素材。 重要:不要把文件内容(base64 / 二进制)放进工具参数,文件由你在本地直接上传。

使用步骤:

  1. 在本地计算文件内容的 md5(32 位小写十六进制,例如「md5sum product.png」)。

  2. 调用本工具,传入 md5 与 contentType,得到 fileId 与 uploadUrl。

  3. 若 uploaded=true,说明该文件已存在,直接使用 fileId,无需上传; 否则把文件原始字节 PUT 到 uploadUrl,Content-Type 与传入的 contentType 一致。uploadUrl 是短链,会 307 跳转到真实上传地址,必须跟随重定向(curl 加 -L)。

  4. 把 fileId 传给后续需要文件的业务工具(例如 AiProductImageSet 的 productImages)。

【上传命令要求】必须让命令真正读取文件字节,不能把路径当内容发出去:

  • curl 正确写法:curl -L -X PUT -H 'Content-Type: <contentType>' --data-binary @<本地文件路径> '<uploadUrl>',路径前必须有 @;-T <本地文件路径> 也会读取文件,二者等价。

  • PowerShell 里的 curl 可能是 Invoke-WebRequest 的别名,不支持上面这些参数,请显式用 curl.exe,或改用 Invoke-WebRequest -Method Put -InFile <本地文件路径>。

  • 错误写法(会把路径字符串当文件内容上传):--data-binary "<本地文件路径>"(漏了 @)、--data-binary <本地文件路径>、-d <本地文件路径>、--data-urlencode <本地文件路径>。

  • 上传后自检:上传的字节数必须等于本地文件大小(wc -c / ls -l 或 curl -IL 的 Content-Length 核对);HTTP 200 不代表内容正确,预签名上传不校验内容。

  • 自检不通过时重新上传正确字节,确认无误后再把 fileId 交给业务工具;不要带着错误的 fileId 继续调业务工具。

fileId 即文件内容的 md5,同一文件重复使用同一个 fileId 即可,无需重复上传。

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "md5": "<md5>",
      "contentType": "<contentType>"
    },
    "name": "CreateUploadUrl"
  }
}

Input Schema

NameRequiredDescriptionDefault
md5Yes文件内容的 md5,32 位小写十六进制。可用「md5sum 文件名」计算。
contentTypeYes文件 MIME 类型,例如 image/png、image/jpeg、image/webp、video/mp4。上传时必须带相同的 Content-Type。

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.6/5.0
Behavior4/5

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

Adds substantial behavior beyond the annotations: the uploaded=true short-circuit, the 307 redirect that must be followed, the warning that HTTP 200 does not mean correct content because presigned uploads don't validate bytes, and the self-check/retry loop. Slight tension with idempotentHint=false since the description says the same file need not be re-uploaded, but that claim concerns the file content (fileId = md5), not the tool call itself, so it is not a true contradiction.

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?

Front-loaded purpose, then numbered steps, then a clearly delimited bracketed section on upload commands. The curl/PowerShell guidance is long relative to a two-parameter tool, but it targets a documented failure mode (uploading the path string instead of bytes) rather than padding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers the full lifecycle — compute hash, call tool, branch on uploaded, PUT with redirect, verify byte count, pass fileId onward — and explains the return values (fileId, uploadUrl, uploaded) even though no output schema exists. Nothing an agent needs to invoke this correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning: md5 is the content hash in 32-char lowercase hex, and fileId is that same md5, which explains why repeat use is safe. It also binds contentType to the Content-Type header that must be sent on the PUT.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a concrete verb+resource (获取文件上传地址) plus scope (图片、视频等各类素材), and it is clearly the only upload/prerequisite tool among a catalog of generation tools. The line about passing fileId to downstream business tools like AiProductImageSet makes its role in the pipeline unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives an explicit 4-step procedure, including the negative rule (don't put base64/binary in params, upload locally instead), the branch condition uploaded=true → skip upload, and the follow-up action of handing fileId to business tools. Alternatives are not needed because no sibling performs uploads.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources