From 5012bea7ca22990284a248a1fc3a2b4784fab314 Mon Sep 17 00:00:00 2001 From: CodeBuddy Attribution Bot Date: Wed, 29 Apr 2026 00:13:04 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix(attribution):=20MCP=20createCloudFuncti?= =?UTF-8?q?on=20=E5=B7=A5=E5=85=B7=E5=8F=82=E6=95=B0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E4=B8=8D=E6=B8=85=E6=99=B0=E5=AF=BC=E8=87=B4=20HTTP=20?= =?UTF-8?q?=E4=BA=91=E5=87=BD=E6=95=B0=E5=88=9B=E5=BB=BA=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=20(issue=5Fmo8ywjss=5Fsiyh6g)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mcp/src/tools/functions.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mcp/src/tools/functions.ts b/mcp/src/tools/functions.ts index 08db62cef..d7baaefa8 100644 --- a/mcp/src/tools/functions.ts +++ b/mcp/src/tools/functions.ts @@ -1449,14 +1449,23 @@ export function registerFunctionTools(server: ExtendedMcpServer) { action: z .enum(MANAGE_FUNCTION_ACTIONS) .describe("写操作类型,例如 createFunction、invokeFunction、attachLayer"), - func: CREATE_FUNCTION_SCHEMA.optional().describe("createFunction 操作的函数配置"), + func: CREATE_FUNCTION_SCHEMA.optional().describe( + "createFunction 操作的函数配置。" + + "\n\n对于 HTTP 函数,必须包含以下字段:" + + "\n- name: 函数名称(必填)" + + "\n- type: \"HTTP\"" + + "\n- protocolType: \"HTTP\" (或 \"WS\" 用于 WebSocket)" + + "\n- runtime: 运行时环境,推荐 \"Nodejs18.15\"。" + + "\n\n对于 HTTP 函数,还必须提供 functionRootPath 或 zipFile 参数来指定代码位置。", + ), functionRootPath: z.string().optional().describe( "创建或更新函数代码时默认推荐的本地目录方式。" + "必须是直接包含函数文件夹的目录绝对路径(如 /abs/path/cloudfunctions 或 /abs/path/functions)," + "不要传项目根目录(如 /abs/path),也不要传到函数名子目录(如 /abs/path/cloudfunctions/hello)。" + "本地应按 cloudfunctions//index.js 或 functions//index.js 布局," + "此参数传 cloudfunctions 或 functions 目录的绝对路径。" + - "SDK 会自动拼接函数名子目录,无需预先压缩 zip 或 base64 编码。", + "SDK 会自动拼接函数名子目录,无需预先压缩 zip 或 base64 编码。" + + "\n\n在创建 HTTP 函数时,如果没有 zipFile 参数,必须提供此参数(HTTP 函数需要有代码位置)。", ), force: z.boolean().optional().describe("createFunction 时是否覆盖"), functionName: z.string().optional().describe("函数名称。大多数 action 使用该字段作为统一目标"), From 3fa6b1cbdd1cc179393c0a172fe91581d27a590f Mon Sep 17 00:00:00 2001 From: bookerzhao Date: Fri, 8 May 2026 11:55:58 +0800 Subject: [PATCH 2/3] docs: strengthen functionRootPath description for HTTP functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 明确说明 HTTP 函数创建时 functionRootPath 必须提供,加强描述以避免参数使用不清晰。 - 更新 functionRootPath 参数说明,强调 HTTP 函数场景 - 明确说明该参数用于指定代码位置 - 不提及 zipFile 参数名 - 与 mcp/src/tools/functions.ts 的参数描述保持一致 --- .../source/skills/cloud-functions/references/http-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/source/skills/cloud-functions/references/http-functions.md b/config/source/skills/cloud-functions/references/http-functions.md index d22bfffb0..ef53d0b7e 100644 --- a/config/source/skills/cloud-functions/references/http-functions.md +++ b/config/source/skills/cloud-functions/references/http-functions.md @@ -245,7 +245,7 @@ manageFunctions({ - `type: "HTTP"` — marks the function as an HTTP Function (not an Event Function). - `protocolType: "HTTP"` — the wire protocol. Use `"WS"` for WebSocket. - `runtime` — the execution runtime. Must match the `scf_bootstrap` binary path. Default is `"Nodejs18.15"` if omitted, but always set it explicitly to avoid ambiguity. -- `functionRootPath` — the parent directory of the function folder (e.g. `/path/to/cloudfunctions` if the code lives in `/path/to/cloudfunctions/myHttpFunction/`). +- `functionRootPath` — 创建或更新函数代码时默认推荐的本地目录方式。必须是直接包含函数文件夹的目录绝对路径(如 `/abs/path/cloudfunctions`),不要传项目根目录或函数名子目录。SDK 会自动拼接函数名子目录。**在创建 HTTP 函数时必须提供此参数**。 ### Security rule configuration From caeb55d46426388b2775a7deae21ecac7a2e75b7 Mon Sep 17 00:00:00 2001 From: CodeBuddy Attribution Bot Date: Fri, 8 May 2026 12:38:32 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix(attribution):=20MCP=20createCloudFuncti?= =?UTF-8?q?on=20=E5=B7=A5=E5=85=B7=E5=8F=82=E6=95=B0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E4=B8=8D=E6=B8=85=E6=99=B0=E5=AF=BC=E8=87=B4=20HTTP=20?= =?UTF-8?q?=E4=BA=91=E5=87=BD=E6=95=B0=E5=88=9B=E5=BB=BA=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=20(issue=5Fmo8ywjss=5Fsiyh6g)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/mcp-tools.md | 6 +++--- mcp/src/tools/functions.ts | 10 +++++----- scripts/tools.json | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/mcp-tools.md b/doc/mcp-tools.md index fabbadabc..a7828766b 100644 --- a/doc/mcp-tools.md +++ b/doc/mcp-tools.md @@ -747,7 +747,7 @@ Manage SQL database resources. Supports MySQL provisioning, MySQL destruction, w { name: "func", type: "object", - description: `createFunction 操作的函数配置`, + description: `createFunction 操作的函数配置。 对于 HTTP 函数,必须包含以下字段: - name: 函数名称(必填) - type: "HTTP" - protocolType: "HTTP" (或 "WS" 用于 WebSocket) - runtime: 运行时环境,推荐 "Nodejs18.15"。 对于 HTTP 函数,默认应提供 functionRootPath 来指定代码目录;zipFile 仅用于已经准备好 base64 代码包的特殊场景,两者至少提供一个。`, children: [ { name: "name", @@ -890,7 +890,7 @@ Manage SQL database resources. Supports MySQL provisioning, MySQL destruction, w { name: "functionRootPath", type: "string", - description: `创建或更新函数代码时默认推荐的本地目录方式。必须是直接包含函数文件夹的目录绝对路径(如 /abs/path/cloudfunctions 或 /abs/path/functions),不要传项目根目录(如 /abs/path),也不要传到函数名子目录(如 /abs/path/cloudfunctions/hello)。本地应按 cloudfunctions//index.js 或 functions//index.js 布局,此参数传 cloudfunctions 或 functions 目录的绝对路径。SDK 会自动拼接函数名子目录,无需预先压缩 zip 或 base64 编码。`, + description: `创建或更新函数代码时默认推荐的本地目录方式。必须是直接包含函数文件夹的目录绝对路径(如 /abs/path/cloudfunctions 或 /abs/path/functions),不要传项目根目录(如 /abs/path),也不要传到函数名子目录(如 /abs/path/cloudfunctions/hello)。本地应按 cloudfunctions//index.js 或 functions//index.js 布局,此参数传 cloudfunctions 或 functions 目录的绝对路径。SDK 会自动拼接函数名子目录,无需预先压缩 zip 或 base64 编码。 创建 HTTP 函数时默认就传这个参数;只有在你明确改走预先打包的 base64 zip 特殊流程时,才不传此参数。`, }, { name: "force", @@ -905,7 +905,7 @@ Manage SQL database resources. Supports MySQL provisioning, MySQL destruction, w { name: "zipFile", type: "string", - description: `仅兼容特殊场景:预先准备好的代码包 base64 编码。普通 createFunction/updateFunctionCode 默认不要先压缩 zip,优先使用 functionRootPath。`, + description: `仅兼容特殊场景:预先准备好的代码包 base64 编码。只有在无法提供 functionRootPath、且你已经有可直接使用的代码包时才使用。普通 createFunction/updateFunctionCode,尤其 HTTP 函数创建,默认都应优先使用 functionRootPath。`, }, { name: "handler", diff --git a/mcp/src/tools/functions.ts b/mcp/src/tools/functions.ts index 73a1929e1..8e794c318 100644 --- a/mcp/src/tools/functions.ts +++ b/mcp/src/tools/functions.ts @@ -389,7 +389,7 @@ export function buildFunctionOperationErrorMessage( if (/paths\[0\].*undefined/i.test(baseMessage)) { suggestions.push( - "HTTP 函数创建时需要提供 functionRootPath(指向 cloudfunctions 或 functions 目录的绝对路径,不是项目根目录)或 zipFile,否则 SDK 无法定位函数目录。", + "HTTP 函数创建时默认应提供 functionRootPath(指向 cloudfunctions 或 functions 目录的绝对路径,不是项目根目录);只有在你已经准备好代码包的 base64 内容时才改用 zipFile,否则 SDK 无法定位函数目录。", ); } @@ -970,7 +970,7 @@ export function registerFunctionTools(server: ExtendedMcpServer) { if (functionType === "HTTP" && !processedRootPath && !input.zipFile) { throw new Error( - "createFunction 创建 HTTP 函数时,需要提供 functionRootPath(指向 cloudfunctions 或 functions 目录的绝对路径,不是项目根目录)或 zipFile。", + "createFunction 创建 HTTP 函数时,默认需要提供 functionRootPath(指向 cloudfunctions 或 functions 目录的绝对路径,不是项目根目录);只有在你已经准备好代码包的 base64 内容时才使用 zipFile。", ); } @@ -1588,7 +1588,7 @@ export function registerFunctionTools(server: ExtendedMcpServer) { "\n- type: \"HTTP\"" + "\n- protocolType: \"HTTP\" (或 \"WS\" 用于 WebSocket)" + "\n- runtime: 运行时环境,推荐 \"Nodejs18.15\"。" + - "\n\n对于 HTTP 函数,还必须提供 functionRootPath 或 zipFile 参数来指定代码位置。", + "\n\n对于 HTTP 函数,默认应提供 functionRootPath 来指定代码目录;zipFile 仅用于已经准备好 base64 代码包的特殊场景,两者至少提供一个。", ), functionRootPath: z.string().optional().describe( "创建或更新函数代码时默认推荐的本地目录方式。" + @@ -1597,12 +1597,12 @@ export function registerFunctionTools(server: ExtendedMcpServer) { "本地应按 cloudfunctions//index.js 或 functions//index.js 布局," + "此参数传 cloudfunctions 或 functions 目录的绝对路径。" + "SDK 会自动拼接函数名子目录,无需预先压缩 zip 或 base64 编码。" + - "\n\n在创建 HTTP 函数时,如果没有 zipFile 参数,必须提供此参数(HTTP 函数需要有代码位置)。", + "\n\n创建 HTTP 函数时默认就传这个参数;只有在你明确改走预先打包的 base64 zip 特殊流程时,才不传此参数。", ), force: z.boolean().optional().describe("createFunction 时是否覆盖"), functionName: z.string().optional().describe("函数名称。大多数 action 使用该字段作为统一目标"), zipFile: z.string().optional().describe( - "仅兼容特殊场景:预先准备好的代码包 base64 编码。普通 createFunction/updateFunctionCode 默认不要先压缩 zip,优先使用 functionRootPath。", + "仅兼容特殊场景:预先准备好的代码包 base64 编码。只有在无法提供 functionRootPath、且你已经有可直接使用的代码包时才使用。普通 createFunction/updateFunctionCode,尤其 HTTP 函数创建,默认都应优先使用 functionRootPath。", ), handler: z.string().optional().describe("函数入口"), timeout: z.number().optional().describe("配置更新时的超时时间"), diff --git a/scripts/tools.json b/scripts/tools.json index 25de23b40..c7bf2c011 100644 --- a/scripts/tools.json +++ b/scripts/tools.json @@ -913,11 +913,11 @@ "name" ], "additionalProperties": false, - "description": "createFunction 操作的函数配置" + "description": "createFunction 操作的函数配置。\n\n对于 HTTP 函数,必须包含以下字段:\n- name: 函数名称(必填)\n- type: \"HTTP\"\n- protocolType: \"HTTP\" (或 \"WS\" 用于 WebSocket)\n- runtime: 运行时环境,推荐 \"Nodejs18.15\"。\n\n对于 HTTP 函数,默认应提供 functionRootPath 来指定代码目录;zipFile 仅用于已经准备好 base64 代码包的特殊场景,两者至少提供一个。" }, "functionRootPath": { "type": "string", - "description": "创建或更新函数代码时默认推荐的本地目录方式。必须是直接包含函数文件夹的目录绝对路径(如 /abs/path/cloudfunctions 或 /abs/path/functions),不要传项目根目录(如 /abs/path),也不要传到函数名子目录(如 /abs/path/cloudfunctions/hello)。本地应按 cloudfunctions//index.js 或 functions//index.js 布局,此参数传 cloudfunctions 或 functions 目录的绝对路径。SDK 会自动拼接函数名子目录,无需预先压缩 zip 或 base64 编码。" + "description": "创建或更新函数代码时默认推荐的本地目录方式。必须是直接包含函数文件夹的目录绝对路径(如 /abs/path/cloudfunctions 或 /abs/path/functions),不要传项目根目录(如 /abs/path),也不要传到函数名子目录(如 /abs/path/cloudfunctions/hello)。本地应按 cloudfunctions//index.js 或 functions//index.js 布局,此参数传 cloudfunctions 或 functions 目录的绝对路径。SDK 会自动拼接函数名子目录,无需预先压缩 zip 或 base64 编码。\n\n创建 HTTP 函数时默认就传这个参数;只有在你明确改走预先打包的 base64 zip 特殊流程时,才不传此参数。" }, "force": { "type": "boolean", @@ -929,7 +929,7 @@ }, "zipFile": { "type": "string", - "description": "仅兼容特殊场景:预先准备好的代码包 base64 编码。普通 createFunction/updateFunctionCode 默认不要先压缩 zip,优先使用 functionRootPath。" + "description": "仅兼容特殊场景:预先准备好的代码包 base64 编码。只有在无法提供 functionRootPath、且你已经有可直接使用的代码包时才使用。普通 createFunction/updateFunctionCode,尤其 HTTP 函数创建,默认都应优先使用 functionRootPath。" }, "handler": { "type": "string",