Skip to content

Commit 9039aa9

Browse files
author
CodeBuddy Attribution Bot
committed
fix(attribution): manageStorage 工具无法获取永久公网访问地址,Agent 误用临时 URL 作为 publicUrl (issue_moj9bllm_n90yq7)
1 parent e2ca73f commit 9039aa9

4 files changed

Lines changed: 23 additions & 4 deletions

File tree

config/.claude/skills/cloudbase-platform/SKILL.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ Use this skill for **CloudBase platform knowledge** when you need to:
107107
- Combine with static hosting file paths to construct final access addresses
108108
- **Important**: If access address is a directory, it must end with `/`
109109

110+
3. **Cloud Storage Public URL**:
111+
- **CRITICAL**: `manageStorage(action=upload)` and `queryStorage(action=url)` return `temporaryUrl` which is a temporary signed URL that expires (default 1 hour). Do NOT use this as a permanent public URL.
112+
- To get the permanent public access URL for a cloud storage object:
113+
1. Call `envQuery(action=info)` to get environment details
114+
2. Extract the storage CDN domain from `EnvInfo.Storages[0].CdnDomain` (e.g., `your-env-id.tcb.qcloud.la`)
115+
3. Construct the public URL: `https://{CdnDomain}/{cloudPath}`
116+
- Example: If `CdnDomain` is `env-xxx.tcb.qcloud.la` and `cloudPath` is `uploads/avatar.jpg`, the public URL is `https://env-xxx.tcb.qcloud.la/uploads/avatar.jpg`
117+
- Note: The public URL is accessible only if the storage bucket ACL allows public read (default is `PRIVATE` which requires signed URLs)
118+
110119
## Environment and Authentication
111120

112121
1. **SDK Initialization**:

config/source/guideline/cloudbase/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ For better UI/UX design, consider reading the `ui-design` skill which provides:
330330
- **MySQL (Tool)**: `relational-database-tool`
331331

332332
### Storage Skills
333-
- **Cloud Storage (Web)**: `cloud-storage-web` - Upload, download, temporary URLs, file management
333+
- **Cloud Storage (Web)**: `cloud-storage-web` - Upload, download, temporary URLs, file management. **Note**: For permanent public URLs, use `envQuery(action=info)` to get `EnvInfo.Storages[0].CdnDomain` and construct `https://{CdnDomain}/{cloudPath}`
334334

335335
### AI Skills
336336
- **AI Model (Web)**: `ai-model-web` - Text generation and streaming via @cloudbase/js-sdk

config/source/skills/cloudbase-platform/SKILL.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ Use this skill for **CloudBase platform knowledge** when you need to:
107107
- Combine with static hosting file paths to construct final access addresses
108108
- **Important**: If access address is a directory, it must end with `/`
109109

110+
3. **Cloud Storage Public URL**:
111+
- **CRITICAL**: `manageStorage(action=upload)` and `queryStorage(action=url)` return `temporaryUrl` which is a temporary signed URL that expires (default 1 hour). Do NOT use this as a permanent public URL.
112+
- To get the permanent public access URL for a cloud storage object:
113+
1. Call `envQuery(action=info)` to get environment details
114+
2. Extract the storage CDN domain from `EnvInfo.Storages[0].CdnDomain` (e.g., `your-env-id.tcb.qcloud.la`)
115+
3. Construct the public URL: `https://{CdnDomain}/{cloudPath}`
116+
- Example: If `CdnDomain` is `env-xxx.tcb.qcloud.la` and `cloudPath` is `uploads/avatar.jpg`, the public URL is `https://env-xxx.tcb.qcloud.la/uploads/avatar.jpg`
117+
- Note: The public URL is accessible only if the storage bucket ACL allows public read (default is `PRIVATE` which requires signed URLs)
118+
110119
## Environment and Authentication
111120

112121
1. **SDK Initialization**:

mcp/src/tools/storage.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export function registerStorageTools(server: ExtendedMcpServer) {
6969
"queryStorage",
7070
{
7171
title: "查询存储信息",
72-
description: "查询云存储信息,支持列出目录文件、获取文件信息、获取临时下载链接等只读操作。返回的文件信息包括文件名、大小、修改时间、下载链接等。",
72+
description: "查询云存储信息,支持列出目录文件、获取文件信息、获取临时下载链接等只读操作。返回的文件信息包括文件名、大小、修改时间、下载链接等。注意:action=url 返回的 temporaryUrl 是临时签名链接,有效期由 maxAge 参数决定(默认1小时)。如需获取永久公网访问地址,请使用 envQuery(action=info) 查询环境信息,从返回的 EnvInfo.Storages[0].CdnDomain 字段获取存储桶 CDN 域名,然后拼接为 https://{CdnDomain}/{cloudPath} 格式的公网访问地址。",
7373
inputSchema: queryStorageInputSchema,
7474
annotations: {
7575
readOnlyHint: true,
@@ -207,7 +207,7 @@ export function registerStorageTools(server: ExtendedMcpServer) {
207207
"manageStorage",
208208
{
209209
title: "管理存储文件",
210-
description: "管理云存储文件,仅用于 COS/Storage 对象,不用于静态网站托管。支持上传文件/目录、下载文件/目录、删除文件/目录等操作。删除操作需要设置force=true进行确认,防止误删除重要文件。",
210+
description: "管理云存储文件,仅用于 COS/Storage 对象,不用于静态网站托管。支持上传文件/目录、下载文件/目录、删除文件/目录等操作。删除操作需要设置force=true进行确认,防止误删除重要文件。注意:上传后返回的 temporaryUrl 是临时签名链接,有效期1小时后会过期。如需获取永久公网访问地址,请使用 envQuery(action=info) 查询环境信息,从返回的 EnvInfo.Storages[0].CdnDomain 字段获取存储桶 CDN 域名,然后拼接为 https://{CdnDomain}/{cloudPath} 格式的公网访问地址。",
211211
inputSchema: manageStorageInputSchema,
212212
annotations: {
213213
readOnlyHint: false,
@@ -264,7 +264,8 @@ export function registerStorageTools(server: ExtendedMcpServer) {
264264
cloudPath: input.cloudPath,
265265
isDirectory: input.isDirectory,
266266
temporaryUrl: fileUrls[0]?.url || "",
267-
expireTime: "1小时"
267+
expireTime: "1小时",
268+
note: "temporaryUrl 是临时签名链接,1小时后过期。如需永久公网访问地址,请调用 envQuery(action=info) 获取 EnvInfo.Storages[0].CdnDomain,拼接为 https://{CdnDomain}/{cloudPath}"
268269
},
269270
message: `Successfully uploaded ${input.isDirectory ? 'directory' : 'file'} from '${input.localPath}' to '${input.cloudPath}'`
270271
}, null, 2)

0 commit comments

Comments
 (0)