@@ -104,6 +104,7 @@ export const MANAGE_FUNCTION_ACTIONS = [
104104 "updateFunctionCode" ,
105105 "updateFunctionConfig" ,
106106 "invokeFunction" ,
107+ "deleteFunction" ,
107108 "createFunctionTrigger" ,
108109 "deleteFunctionTrigger" ,
109110 "createLayerVersion" ,
@@ -1147,6 +1148,30 @@ export function registerFunctionTools(server: ExtendedMcpServer) {
11471148 throw error ;
11481149 }
11491150 }
1151+ case "deleteFunction" : {
1152+ if ( ! input . functionName ) {
1153+ throw new Error ( "deleteFunction 操作时,functionName 参数是必需的" ) ;
1154+ }
1155+ requireConfirm ( input . action , input . confirm ) ;
1156+ const cloudbase = await getManager ( ) ;
1157+ const result = await cloudbase . functions . deleteFunction ( input . functionName ) ;
1158+ logCloudBaseResult ( server . logger , result ) ;
1159+ return buildEnvelope (
1160+ {
1161+ action : input . action ,
1162+ functionName : input . functionName ,
1163+ raw : result ,
1164+ } ,
1165+ `已删除函数 ${ input . functionName } ` ,
1166+ [
1167+ {
1168+ tool : "queryFunctions" ,
1169+ action : "listFunctions" ,
1170+ reason : "确认函数已被删除" ,
1171+ } ,
1172+ ] ,
1173+ ) ;
1174+ }
11501175 case "createFunctionTrigger" : {
11511176 if ( ! input . functionName ) {
11521177 throw new Error ( "createFunctionTrigger 操作时,functionName 参数是必需的" ) ;
@@ -1448,7 +1473,7 @@ export function registerFunctionTools(server: ExtendedMcpServer) {
14481473 inputSchema : {
14491474 action : z
14501475 . enum ( MANAGE_FUNCTION_ACTIONS )
1451- . describe ( "写操作类型,例如 createFunction、invokeFunction、attachLayer" ) ,
1476+ . describe ( "写操作类型,例如 createFunction、updateFunctionCode、 invokeFunction、deleteFunction 、attachLayer" ) ,
14521477 func : CREATE_FUNCTION_SCHEMA . optional ( ) . describe ( "createFunction 操作的函数配置" ) ,
14531478 functionRootPath : z . string ( ) . optional ( ) . describe (
14541479 "创建或更新函数代码时默认推荐的本地目录方式。" +
@@ -1482,7 +1507,7 @@ export function registerFunctionTools(server: ExtendedMcpServer) {
14821507 . optional ( )
14831508 . describe ( "updateFunctionLayers 的目标层列表,顺序即最终顺序" ) ,
14841509 codeSecret : z . string ( ) . optional ( ) . describe ( "层绑定时的代码保护密钥" ) ,
1485- confirm : z . boolean ( ) . optional ( ) . describe ( "危险操作确认开关" ) ,
1510+ confirm : z . boolean ( ) . optional ( ) . describe ( "危险操作确认开关。deleteFunction、deleteFunctionTrigger、deleteLayerVersion、detachLayer 等删除类操作需要显式传入 confirm=true " ) ,
14861511 } ,
14871512 annotations : {
14881513 readOnlyHint : false ,
0 commit comments