File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ export function registerFunctionTools(server: ExtendedMcpServer) {
8989 vpcId : z . string ( ) ,
9090 subnetId : z . string ( )
9191 } ) . optional ( ) . describe ( "私有网络配置" ) ,
92- runtime : z . string ( ) . optional ( ) . describe ( "运行时环境,建议指定为 'Nodejs 18 .15',其他可选值:" + SUPPORTED_NODEJS_RUNTIMES . join ( ',' ) ) ,
92+ runtime : z . string ( ) . optional ( ) . describe ( "运行时环境,建议指定为 'Nodejs18 .15',其他可选值:" + SUPPORTED_NODEJS_RUNTIMES . join ( ',' ) ) ,
9393 triggers : z . array ( z . object ( {
9494 name : z . string ( ) ,
9595 type : z . string ( ) ,
@@ -122,6 +122,20 @@ export function registerFunctionTools(server: ExtendedMcpServer) {
122122 // 自动填充默认 runtime
123123 if ( ! func . runtime ) {
124124 func . runtime = DEFAULT_NODEJS_RUNTIME ;
125+ } else {
126+ // 验证 runtime 格式,防止常见的空格问题
127+ const normalizedRuntime = func . runtime . replace ( / \s + / g, '' ) ;
128+ if ( SUPPORTED_NODEJS_RUNTIMES . includes ( normalizedRuntime ) ) {
129+ func . runtime = normalizedRuntime ;
130+ } else if ( func . runtime . includes ( ' ' ) ) {
131+ console . warn ( `检测到 runtime 参数包含空格: "${ func . runtime } ",已自动移除空格` ) ;
132+ func . runtime = normalizedRuntime ;
133+ }
134+ }
135+
136+ // 验证 runtime 是否有效
137+ if ( ! SUPPORTED_NODEJS_RUNTIMES . includes ( func . runtime ) ) {
138+ throw new Error ( `不支持的运行时环境: "${ func . runtime } "。支持的值:${ SUPPORTED_NODEJS_RUNTIMES . join ( ', ' ) } ` ) ;
125139 }
126140
127141 // 强制设置 installDependency 为 true(不暴露给AI)
Original file line number Diff line number Diff line change 506506 },
507507 "runtime" : {
508508 "type" : " string" ,
509- "description" : " 运行时环境,建议指定为 'Nodejs 18 .15',其他可选值:Nodejs18.15, Nodejs16.13,Nodejs14.18,Nodejs12.16,Nodejs10.15,Nodejs8.9"
509+ "description" : " 运行时环境,建议指定为 'Nodejs18 .15',其他可选值:Nodejs16.13,Nodejs14.18,Nodejs12.16,Nodejs10.15,Nodejs8.9"
510510 },
511511 "triggers" : {
512512 "type" : " array" ,
You can’t perform that action at this time.
0 commit comments