Skip to content

Commit 838f028

Browse files
committed
fix(functions): 🔧 remove runtime parameter from updateFunctionCode to prevent modification error
1 parent 4a19751 commit 838f028

File tree

4 files changed

+585
-277
lines changed

4 files changed

+585
-277
lines changed

doc/mcp-tools.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ classDiagram
394394
### `updateFunctionCode`
395395
更新函数代码
396396

397+
**注意**:此工具仅用于更新已存在函数的代码,不支持修改函数配置(如 runtime)。如果需要修改 runtime,需要删除函数后使用 `createFunction` 重新创建。
398+
397399
#### 参数
398400

399401
<table>

mcp/src/tools/functions.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export function registerFunctionTools(server: ExtendedMcpServer) {
221221
"updateFunctionCode",
222222
{
223223
title: "更新云函数代码",
224-
description: "更新函数代码",
224+
description: "更新已存在函数的代码。注意:此工具仅用于更新代码,不支持修改函数配置(如 runtime)。如果需要修改 runtime,需要删除函数后使用 createFunction 重新创建。",
225225
inputSchema: {
226226
name: z.string().describe("函数名称"),
227227
functionRootPath: z.string().describe("函数根目录(云函数目录的父目录),这里需要传操作系统上文件的绝对路径"),
@@ -237,28 +237,22 @@ export function registerFunctionTools(server: ExtendedMcpServer) {
237237
category: "functions"
238238
}
239239
},
240-
async ({ name, functionRootPath, zipFile, handler, runtime }: {
240+
async ({ name, functionRootPath, zipFile, handler }: {
241241
name: string;
242242
functionRootPath?: string;
243243
zipFile?: string;
244244
handler?: string;
245-
runtime?: string;
246245
}) => {
247-
// 自动填充默认 runtime
248-
if (!runtime) {
249-
runtime = DEFAULT_NODEJS_RUNTIME;
250-
}
251-
252246
// 处理函数根目录路径,确保不包含函数名
253247
const processedRootPath = processFunctionRootPath(functionRootPath, name);
254248

255249
// 构建更新参数,强制设置 installDependency 为 true(不暴露给AI)
250+
// 注意:不包含 runtime 参数,因为云开发平台不支持修改已存在函数的 runtime
256251
const updateParams: any = {
257252
func: {
258253
name,
259254
installDependency: true,
260-
...(handler && { handler }),
261-
...(runtime && { runtime })
255+
...(handler && { handler })
262256
},
263257
functionRootPath: processedRootPath
264258
};

0 commit comments

Comments
 (0)