download_file
下载一个文件, 按 MCP spec 2025-06-18 的原生 content 类型返回。
根据文件 category 自动选择最合适的 MCP content block 类型:
- image (jpg/png/webp/...) → content[0].type = "image"
(base64 + mimeType; AI 客户端原生显示图片, 多模态 LLM 可直接看图)
- audio (mp3/wav/...) → content[0].type = "audio"
(base64 + mimeType; AI 客户端原生播放, 多模态模型可直接听)
- text/code + as_text=true → content[0].type = "text"
(UTF-8 字符串; 适合代码/文档阅读分析)
- 其他所有 (video / document / archive / 大文本 / ...)
→ content[0].type = "resource_link"
(15 分钟有效的 URL + mimeType + size; 签名自带, 无需 Authorization;
AI 用 bash curl 拉字节, 或提示用户点链接在浏览器下载)
【限速】所有分支都遵守会员档位的 download_speed_bytes_per_sec 设定:
- image / audio / text 分支走 astream_file(throttle=...) 读字节再 base64
- resource_link 分支: 链接指向 /api/v1/mcp-download/{token}, 目标路由
也用同一套 astream_file + throttle 算法 (详见 api/v1/mcp_download.py)
【零副作用】不再使用 share_service.create_share —— MCP 下载不会在你的
账号里留下任何公开分享记录, 不进分享面板, 不计分享审计。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| as_text | No | 【仅文本/代码文件】直接返 UTF-8 字符串文本内容。图片/音频等非文本文件不受此参数影响(它们按 MCP 原生 content type 返回)。 | |
| file_id | No | ||
| file_uuid | No |